Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13951

Why is plt.savefig() not working in texstudio?

$
0
0

I am trying to make a simple graph to show in my latex document using pythontex and it seems that plt.savefig() is not working. Here is the code i used for testing:

% !TeX TXS-program:compile = txs:///pythontex\documentclass[a4paper, 12pt]{article}\usepackage{pythontex}\usepackage{mathtools, amsthm, amssymb, icomma, upgreek, xfrac}\usepackage[utf8]{inputenc}\usepackage{lmodern, microtype}\usepackage{pgfplots}\usepackage{graphicx}\begin{document}\begin{pycode}import numpy as npimport matplotlib.pyplot as pltimport matplotlibx = np.linspace(-10, 10, 20)f = 2*xplt.plot(x, f)plt.savefig('C:\\test\\1.png')\end{pycode}\end{document}

I tried to save image in specific locaiton like 'C:\test\1.png' and it didn't work. Tried to update matplotlib, it didn't work either. I simply want the png file to save in folder with the .tex file, so i can use it later in the document.


Viewing all articles
Browse latest Browse all 13951

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>