openPMD-viewer icon indicating copy to clipboard operation
openPMD-viewer copied to clipboard

How to rotate the axes

Open HLQzZ opened this issue 2 years ago • 2 comments

When I set slice_across='y' and plot=True in ts.get_field, what I draw is a picture of the x-z plane, but I want to rotate the coordinate axis to draw a picture of the z-x plane, what should I do?

HLQzZ avatar Apr 14 '23 03:04 HLQzZ

Instead of plot=True you can take the numpy 2D array that the ts.get_field returns, transpose it as usual with .T and then plug it into matplotlib's plt.imshow().

Data API:

  • https://github.com/openPMD/openPMD-viewer/blob/dev/tutorials/1_Introduction-to-the-API.ipynb

Numpy:

  • https://numpy.org/doc/stable/reference/generated/numpy.ndarray.T.html

Matplotlib:

  • https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.imshow.html
  • https://matplotlib.org/stable/gallery/images_contours_and_fields/image_demo.html

ax3l avatar Apr 20 '23 18:04 ax3l

Thank you very much, this problem has been solved. Another question is how to select a specific id format in select like select=[id]? And how to write or such as x=[None,-8e-6]or[8e-6,None], thank you!

HLQzZ avatar May 29 '23 02:05 HLQzZ