4 ms·
emacs org mode can do this but is not tied to just python. Anyway, something like this works: #+BEGIN_SRC python :results file import matplotlib matplotl
by toolslive 3y ago
emacs org mode can do this but is not tied to just python. Anyway, something like this works:
#+BEGIN_SRC python :results file
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
fn = 'my_fig.png'
plt.plot([1, 2, 3, 2.5, 2.8])
plt.savefig('my_fig.png', dpi=50)
return fn
#+END_SRC
#+RESULTS:
[[file:my_fig.png]]
- bjornasm 3y agoIn a true notebook you would maybe want to do the following: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt plt.plot([1, 2, 3, 2.5, 2.8]) Alright, saving the figure at 50 dpi first plt.savefig('my_fig.png', dpi=50) Trying a bit more DPI to see if that makes a difference plt.savefig('my_fig2.png', dpi=150) Oh, wrong numbers, forgot that the fourth datapoint was going to signify 100, going back to 50 dpi as well plt.plot([1, 2, 3, 100, 2.3]) plt.savefig('my_fig4.png', dpi=50) It seems like your example misses the interactivity.