Emmanuel
Emmanuel

Reputation: 14209

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 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

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.

Upvotes: 41

Views: 98084

Answers (2)

user707650
user707650

Reputation:

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.

Upvotes: 25

Emmanuel
Emmanuel

Reputation: 14209

I managed to do so, on Evert's advice, by using a very big resolution with a very small font. Here are the most important steps:

import pylab as pl
pl.figure(figsize=(70, 70)) # This increases resolution
pl.savefig('test.eps', format='eps', dpi=900) # This does, too
pl.annotate(..., fontsize='xx-small', ...)

Upvotes: 43

Related Questions