Matplotlib, savefig: DPI setting is ignored

I can not find anyone else with this problem. In matplotlib, you can view your stories using either show () or savefig (). They generate slightly different images; in my case, the savefig () image is uglier and harder to understand. I need to make life easy for my examiner, therefore ..

I found several topics that suggested that I set the DPI size to match the show () metric. I tried:

-> Install savefig.dpi directly using matplotlib.rcParams ['savefig.dpi'] = 80.

-> Install savefig.dpi directly into ~ / .matplotlib / matplotlibrc.

-> Moving my rc file to CWD.

-> Finally, using savefig ('image.pdf', dpi = 80)

I can check if the attribute is really set; but it seems that the setting is activated using savefig (). Can anyone help with this?

(Simplified) code:

plt.bar(ind, functimes, yerr=stddev, bottom=0, width=barWidth, align='center', color='b') ax = plt.gca() ax.legend(barRcts, barLegend) plt.title("Function Call Overhead") plt.xlabel("Function ID") plt.ylabel("Execution Time [us]") plt.xticks(ind, funcNames) figtest.autofmt_xdate() plt.savefig(out_file, dpi=80, format='pdf') 
+6
source share
1 answer

Saving PDF uses the DPI setting to resolve the image inside the PDF, and not for any line / polygon resolution (which does not make sense in vector format).

If you are happy with the result on the screen and do not need scalable graphics, saving as png is probably good.

+3
source

Source: https://habr.com/ru/post/913008/


All Articles