0

I'd like to know why matplotlib outputs plots in different styles depending on which system I run the file. For example, I let the same code run twice, once on a Windows machine and once on Ubuntu system, and got the following two plots

Windows version Ubuntu version The information in the plots is obviously the same, but is there a special command to let matplotlib know that I'd, for example, would like all my plots to be produced in the "Ubuntu style" (lower of the two) version?

5
  • It's to do with the backend that is used - it's different by default for Windows and Unix. matplotlib.org/faq/usage_faq.html#what-is-a-backend You can set it like this: backend : WXAgg Commented Nov 16, 2018 at 13:05
  • 1
    You have two different versions of matplotlib installed on both systems. Check the version via print(matplotlib.__version__). Obviously you can install the same version on all your computers and get the same output. I don't know which of the two plots you call "Ubuntu style", which would be important to know for alternative solutions. Commented Nov 16, 2018 at 13:08
  • It has nothing to do with the backend though, as claimed by the other comment. Commented Nov 16, 2018 at 13:09
  • @ImportanceOfBeingErnest Thanks for the info, I edited the question. Would still be nice to know how I could change it to the other version withou having to install different versions. Commented Nov 16, 2018 at 13:11
  • Ah yes you're right @ImportanceOfBeingErnest Commented Nov 16, 2018 at 13:27

1 Answer 1

3

The upper plot is produced with a version of matplotlib >= 2.0. The lower plot is produced with a version < 2.0. The style changes are documented in the Changes to the default style.

It's hardly possible to make a matplotlib version < 2.0 produce the exact output you'd get with matplotlib >= 2.0, although you might copy the style sheet from a newer version to the old one and set the parameters accordingly.

The inverse is however possible. To get the old (classic) style in a new version of matplotlib should be possible via

import matplotlib.pyplot as plt
plt.style.use("classic") 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.