This question already has an answer here:
3D figures from Matplotlib visibility of pane edge
(1 answer)
Closed 11 hours ago.
In 3D plot by default matplotlib draws axes like the first image. How can we draw more edges parallel to the axes like the second or third images. Found out Scidavis default plot type is like the third image. https://scidavis.sourceforge.net/manual/x528.html
Finally, found a way here myself. A interesting work around to this problem.
Missing spine in 3d plot
Related
This question already has answers here:
How to draw rectangle outside of the plot frame in Matplotlib
(2 answers)
How to position a matplotlib patch outside of the axes range (so that it could be next to the title, or legend, or anywhere on the figure)
(2 answers)
Closed 5 months ago.
I would like to draw a rectangle over a matplotlib figure, in a way that allows overlaying the axes.
The answers I found online only allow drawing a rectange inside the axes, but not overlaying them.
EDIT: This answer allows drawing outside the plot frame. However it does not overlay the axis. Namely, the axis is kept visible. See the example where the axis is still visible behind the red rectangle
See an example below for what I wish to achieve (Code for the bar plot can be taken from here. For the example, the figure was edited with a simple paint software).
It is drawn via matplotlib.pyplot.hist() function in matplotlib
I'm using Python, and I have some data which can be projected on to points within an equilateral triangle whose side lengths sum to 1.
I'm not sure if there is an easy way to visualise a plot like this from Matplotlib or similar libraries, or if I'm just going to have to use a drawing package from scratch to make it happen. Any pointers gratefully recieved. Thanks!
If all you want to do is plot a few dots on a graph, you can infact use Matfplotlib's scatter plots for this:
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.scatter.html
Using plt.xlim(*min*, *max*) and plt.ylim(*min*, *max*), you can set the limits of the graph manually to fit your values (might not be neccessary though).
You can draw lines on the graph for the triangle shape (if you need that): How to draw a line with matplotlib?
If you don't need a scale, you can even remove that to have a blank canvas: Matplotlib plots: removing axis, legends and white spaces
This question already has answers here:
Scatter plot and Color mapping in Python
(4 answers)
Closed 3 years ago.
I am currently working on a project that deals with a scatter plot, made using matplotlib and numpy,
I was wondering whether I could assign color to each point based on their (x,y) coordinates, assume that I have a function that maps (x,y) to (r,g,b). There are a lot of points (~250,000).
Is there any possible way to achieve this?
Matplotlib's scatter plot supports this via the color parameter, check this example. You have to prepare your colors beforehand and pass it to the color. As mentioned, color can be a sequence.
Another way, maybe slightly faster, would be to use seaborn's scatter plot.
I have a Matplotlib scatter plot with 10,000+ points that I plan to insert as a figure in a LaTeX document for publication.
I would like the plot points to be raster graphics (e.g. PNG) because vector graphics with that many points often causes problems for PDF readers. I would like the ticks and axes labels to be vector graphics so I don't have to worry about resolution issues for the text and lines.
Is there a simple way to get matplotlib to make parts of the plot raster graphics while keeping the axes/ticks vector graphics?
My best guess so far is to do some sort of pre-render to PNG then imshow the resulting image with appropriate axes bounds before saving to PDF.
Add rasterized=True to the call to plt.scatter
See the docs here
You can control the dpi of the rasterized parts of the figure by setting dpi=300 (for example) in the call to plt.figure
What I am doing wrong here? I want to plot samples/data on top of my map(pixel plot).I have two different input data- one is for drawing a contour line, and another one I am using to plot samples on top of that contour map.
It can be seen here: