Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
263 views
in Technique[技术] by (71.8m points)

python - matplotlib - increase resolution to see details

I have a big process that is composed of tasks (about 600), and I created a figure to watch the order they are launched with and the time they take. To do this, I used matplotlib and a barh.

The figure is ok (my 1st matplotlib success !), but:

  • I would like to see the details and zoom on the picture when exported (as PNG, for instance), as the zoom option allows when matplotlib displays the result with the show() command
  • the legends of the Y axis are too close and unreadable

I tried to increase the resolution as said in this other SO post, this is better but details are not precise enough. Here are my results so far:

  • full result

full

  • zoom with matplotlib

zoom

Do you know how I could improve readability ? Thanks a lot (else, all my efforts would be useless, I'm afraid...)

PS: I'm using matplotlib 1.1.1 and python 2.7.

question from:https://stackoverflow.com/questions/12192661/matplotlib-increase-resolution-to-see-details

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just for the record, I will put the suggestion done in my second comment here as a possible answer as well. This may not always work, but a test shows good results:

import pylab as pl
pl.figure(figsize=(7, 7))  # Don't create a humongous figure
pl.annotate(..., fontsize=1, ...)   # probably need the annotate line *before* savefig
pl.savefig('test.pdf', format='pdf')   # no need for DPI setting, assuming the fonts and figures are all vector based

It would appear even fractional fontsizes (e.g. fontsize=0.1) works. Your mileage may vary: I have tested this only with the PDF backend, not the EPS one.

Also: I have left out the DPI setting. When printing this on a high resolution printer, you may need it again. Then again, you shouldn't, as this likely is a printer setting instead: how the printer rasterizes your (vector) PDF image. I simply don't know if these kind of "hints" can be coded into postscript/PDF.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...