0

I solved one hyperbolic pde using 4096 points in x-axis and 10000 points in t-axis, so now I have a matrix u with 4096 lines and 10000 columns, i.e. for every point on x-axis I have solve a ode in t. So now I need to see the solution on a 3d graph, but python is complaining about dimensions of my vectors that represent the domain, begging for the vector that contains my points for t to have the same dimension of my correspondent vector for x.

surf = ax.plot_trisurf(x, t, sol[:,:, 0], cmap=cm.jet, linewidth=0.1)

I have used the code above to try to do the plot, but python says "ValueError: x and y must be equal-length 1-D arrays" I also tried to find some function analogous to the "mesh" function of matlab, which I do this what I'm trying using just one line that is

mesh(x,t,u)

There is some manner to do this using matplotlib or some analogous function to the matlab's mesh function ?

mcirqueira
  • 11
  • 1
  • 2
  • `plot_trisurf` would expect one x value for each y value for each z value in 1D lists. Since it looks like your data is on a grid, you would probably rather use `plot_surface`? – ImportanceOfBeingErnest Aug 11 '19 at 21:58
  • @ImportanceOfBeingErnest I tried now but I'm having an error "shape mismatch", trying with ```python surf = ax.plot_surface(xx, tt, sol[:,:,0], cmap=cm.jet, linewidth=0.1) ``` where xx and tt are the output of np.meshgrid – mcirqueira Aug 11 '19 at 22:28
  • That sounds good. you can print the shapes of the arrays and check if they are as expected (`print(xx.shape)` etc.). Else you need to provide a [mcve] in the question. – ImportanceOfBeingErnest Aug 11 '19 at 22:34

0 Answers0