Python's matplotlib does not generate Retina display quality LaTeX text by default. Are there settings or add-on package that generate Retina quality output?
Are you using 'Agg' mode (standard) to create PNG Graphs?
You can create SVG Graphs with Matplot lib which have way better quality using
matplotlib.use('svg')
If you look into texmanager.py you see that it makes the png by a call to dvipng and the function that makes the system call to dvipng has an argument for dpi
To get higher resolution TeX on a per-figure basis for existing figures
plt.gcf().canvas.renderer.dpi = what_ever_retina_dpi_is
to set it everywhere, you should be able to set the rcparam figure.dpi which will be respected when creating new renderers.
I can't test this as I do not have access to a Mac with a Retina display.
Related
When I use Matplotlib's plt.show() I get a nice Plot which can can be zoomed to very high precision(practically infinite). But when I save it as a image it loses all this information gives information depending on resolution.
Is there any way I can save the plot with the entire information? i.e Like those interactive plots which can rescaled at any time?
P.S- I know I can set dpi to get high quality images. This is not what I want. I want image similar to Plot which python shows when I run the program. What format is that? Or is it just very high resolution image?
Note- I am plotting .csv files which includes data varying from 10^(-10) to 100's. Thus when I save the plot as .png file I lose all the information/kinks of graph at verн small scales and only retain features from 1-100.
Maybe the interactive graphic library bokeh is an option for you. See here. It's API is just little different from what you know from matplotlib.
Bokeh creates plots as html files that you can view in your browser. For each graphic you can select wheel zoom to zoom interactively into your graphic. You can change interactively the range that you want to be plotted. Therefore you don't loose information in your graphic.
I am using Python's scientific plotting library matplotlib. I am trying to use matplotlib to show an image using imshow. I would like to be able to adjust the color range with in the figure with some type of UI. From what I can tell, there isn't a built-in way to do this in matplotlib, and I have found much on this issue. This is a fairly common use-case and easy to do in MATLAB. How does one do this in matplotlib?
I'm assuming you want to change the cmap attribute. You could use the built-in function input to read some new value from the command line (not really a GUI) or you could use the matplotlib.widgets package which includes e.g. a slider and buttons (see this link for examples).
I have started to use matplotlib-venn for plotting venn diagram. It's a very useful tool, but I would like to know whether the graph generated can be saved in an SVG (or even pdf) format. I want to keep the graph vector, not rasterize it as in png.
I think there is a way, so if you can point me to it, that would be very helpful.
You can use the standard savefig method. Just give your output path a '.svg' extension:
from matplotlib_venn import venn2
import matplotlib.pyplot as plt
venn2(subsets = (3, 2, 1))
plt.savefig('venn2.svg')
You can save to PNG with a .png extension and... you can probably see where this is going for other formats.
Looks like you need to configure the SVG 'backend':
The matplotlib frontend or matplotlib API is the set of classes that
do the heavy lifting, creating and managing figures, text, lines,
plots and so on (Artist tutorial). This is an abstract interface that
knows nothing about output. The backends are device-dependent drawing
devices, aka renderers, that transform the frontend representation to
hardcopy or a display device (What is a backend?). Example backends:
PS creates PostScript® hardcopy, SVG creates Scalable Vector Graphics
hardcopy,...
> # The default backend; one of GTK GTKAgg GTKCairo GTK3Agg GTK3Cairo
> # CocoaAgg MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG
> # Template.
> # You can also deploy your own backend outside of matplotlib by
> # referring to the module name (which must be in the PYTHONPATH) as
> # 'module://my_backend'. backend : qt4agg
Src: http://matplotlib.org/Matplotlib.pdf
I am looking to replace a MATLAB GUI used to do manual scoring of objects within a tif file. Someone recommended Bokeh to me. Is it possible to read a tif-file using any module and allow interactivity via Bokeh?
I have not used Bokeh (but I have kept an eye on it), so my answer is: Yes, you could probably use Bokeh for this.
But considering that you are replacing a MATLAB GUI, I think there might be an easier way. Bokeh creates plots that run in your web browser, which might not be what you want.
Instead, you could look into using matplotlib to do it.
The PyPlot API in matplotlib is very similar to the plot functions in MATLAB, and it supports creating interactive plots.
To read the TIFF file I would recommend looking into either PIL or OpenCV.
I have some GPS position recordings, which I want to draw into a map (e.g. OpenStreetMap) and save this as an image file.
I'm using python. I've found osm-gps-map as a candidate library to do the visualization, but apparantly the API lacks some functionality to satisfy all of my needs. What I need is a library that does:
draw stuff into a map (e.g. an OSM-based map), i.e. a list of GPS positions.
automatically adjust view (scale/position) to fit in all drawn positions
save this view to an image file
I seriously want to avoid being forced to manually make a screenshot from a widget or a browser window. And if possible I also want to avoid to implement the necessary projection functionality by myself (as in here). Does anyone know a library/toolchain that provides the desired functionality (if possible for use by Python)?
You may want to consider using Basemap for matplotlib. Here is a blog post describing how to use this package with OSM.
There are examples of how to draw custom GPS points on top of OSM background map using Matplotlib Basemap, Matplotlib or Cairo in GeoTiler project: https://github.com/wrobell/geotiler/tree/master/examples.