How can I make a surface plot animation like this one:
The 3d plot is viewed from the top. I made that using GNU Octave.
How to do it in Manim? I only know it can make surface plot using checker board colormap. How to do it so the result will be similar as Matlab/Octave? With rich colormap. For example this colormap:
My plan is to do the computation in Octave, and then use the numerical result to make animation in Manim.
Is it possible to use mpldatacursor with the python matplotlib function pcolormesh()?
Yes, it it possible to use mpldatacursor with pcolormesh. However, since pcolormesh is defined by the edges of the grid, you need to click on the edges of the pixels for the cursor to appear.
I would like to make the background of my imshow plots transparent. I know I can do this using the color to alpha option in GIMP. However, using GIMP in this case is not an option as I still need to perform actions after the background of imshow has been made transparent.
Is there a way to remove the background of imshow plots similar to GIMP's color to alpha in python without saving the figure first?
I'm looking for a way to use matplotlib's 3D plotting
capabilities to display a flat image (a png or tiff) in 3D
space for some visualization I'd like to do.
The documentation is not very helpful,
is this even possible?
Here's a post that shows how to do what you're looking for.
Image overlay in 3d plot using python
I am using matplotlib to make some graphs and unfortunately I cannot export them without the white background.
In other words, when I export a plot like this and position it on top of another image, the white background hides what is behind it rather than allowing it to show through. How can I export plots with a transparent background instead?
Use the matplotlib savefig function with the keyword argument transparent=True to save the image as a png file.
In [30]: x = np.linspace(0,6,31)
In [31]: y = np.exp(-0.5*x) * np.sin(x)
In [32]: plot(x, y, 'bo-')
Out[32]: [<matplotlib.lines.Line2D at 0x3f29750>]
In [33]: savefig('demo.png', transparent=True)
Result:
Of course, that plot doesn't demonstrate the transparency. Here's a screenshot of the PNG file displayed using the ImageMagick display command. The checkerboard pattern is the background that is visible through the transparent parts of the PNG file.
Png files can handle transparency.
So you could use this question Save plot to image file instead of displaying it using Matplotlib so as to save you graph as a png file.
And if you want to turn all white pixel transparent, there's this other question : Using PIL to make all white pixels transparent?
If you want to turn an entire area to transparent, then there's this question: And then use the PIL library like in this question Python PIL: how to make area transparent in PNG? so as to make your graph transparent.
As a reminder, the plt.savefig() should be written before the plt.show(), otherwise, a transparent image will be created (without the actual plot).
For high-quality images:
plt.savefig('filename.png', format='png', dpi='600', transparent=True)
plt.show()