Questions tagged [matplotlib]

Matplotlib is a 2D plotting library for Python, built on NumPy and often used interactively with IPython. Its "pylab" interface is similar to the plotting functions of MATLAB®.

Filter by
Sorted by
Tagged with
2 votes
1 answer
76 views

Matplotlib PGF backend packages installed by Latex

I want to produce an image to use in Latex. The PDF image is quite large (~200 MB), and as a solution, I wanted to use the PGF backend. So, using the guide here, I added this line: plt.savefig('figure....
user avatar
  • 125
1 vote
0 answers
44 views

Legend and axis label of pgf plot displayed differently in beamer

I created different plots with matplotlib, which I export as .pgf files. I then import these plots again in latex to display them in my document. This process works fine with the following code: ...
user avatar
  • 113
8 votes
0 answers
81 views

Using some packages adds a vertical offset when using LaTeX to render text in matplotlib/python figures

I was advised to post here in the comments on a post I made on Stack Overflow. I'm using LaTeX to render my text in figures in the Python package matplotlib. My problem was that when I added siunitx ...
user avatar
1 vote
0 answers
73 views

Create font package to use custom vectorial symbols via FontForge

This question builds upon my attempt to include custom, vectorial, LaTeX symbols inside Python plots via tikz, which (so far) is failing due to the impossibility (my inability ?) to attach proper font ...
user avatar
  • 21
1 vote
0 answers
88 views

Creating new symbols with full font-metrics and vector quality

(Note: this question is similar to quite a few others on SO (e.g. this one, that one, that other one, ... but I could find none discussing the explicit need for the new symbols to have proper font ...
user avatar
  • 21
0 votes
0 answers
60 views

Using PythonTex in Lyx on a Mac

I would like to use PythonTex in Lyx on a Mac. I don't understand the intricacy of Lyx/Tex etc. I think I managed to install PythonLex by installing MacTex 2021 which also installed Tex Live Utility ...
user avatar
0 votes
2 answers
281 views

matplotlib pgf backend with lualatex - non-math font does not change

When using Python's matplotlib to produce plots, I sometimes require the lualatex engine using the pgf backend for matplotlib when producing "heavier" plots like hexbin, otherwise the TeX ...
user avatar
0 votes
0 answers
52 views

Are there any potential risks of avoiding type 3 fonts when using matplotlib to draw figures

Many conferences/journals start asking me to use Type 1 font in the submitted PDF. So when I use matplotlib to generate figures, I have two choices: Configure matplotlib to only use tex fonts ...
user avatar
  • 133
3 votes
1 answer
500 views

twinx x-ticklabels not showing properly when input to latex document

I have a plot with two datasets, using the same x-axis data, so I want to plot this using the twinx functionality in python's matplotlib. To typeset the resulting graph in my latex document that the ...
user avatar
  • 33
1 vote
3 answers
675 views

Matplotlib, Inkscape, TeXStudio workflow SVG figures

When I create an SVG figure in matplotlib import numpy as np import matplotlib.pyplot as plt import matplotlib new_rc_params = {'text.usetex': False, "svg.fonttype": 'none' } matplotlib....
user avatar
1 vote
0 answers
121 views

Error in Matplotlib in legend

If I include this plt.legend(['$0.25+\zeta$'], loc = 1)in my code, I am not getting error. But plt.legend(['$\frac{1}{4}+\frac{\alpha}{10}$'], loc = 1) gives error.
user avatar
  • 3,027
3 votes
0 answers
104 views

Dimension too large for this tikz. How to resolve?

I am using MATLAB to plot some graphs and then using matlab2tikz() to convert these MATLAB graphs to tikz. The issue I have now is that one of the graphs I have after converting it to tikz, failed to ...
user avatar
2 votes
1 answer
315 views

Writing probability density function in Latex

How to write the following probability density function for gaussian distribution in Latex (Matplotlib) p(x) = \frac{1}{\sqrt{ 2 \pi \sigma^2 }} e^{ - \frac{ (x - \mu)^2 } {2 \sigma^2} },
user avatar
0 votes
0 answers
1k views

Matplotlib : Why doesn't legend font appear as Latex rendering

Below the PDF output generated by a Python script : As you can see, labels and title are correctly appearing as Latex rendering. Excepted the fact that Latex font is not applied for legend and I don'...
user avatar
0 votes
0 answers
26 views

Issue about mixing font labels text and maths equations with \bm option

I try to generate a pdf from this source in python (matplotlib), in order to have a Latex style : mpl.use("pgf") rc_fonts = { "text.usetex": True, 'text.latex.preview': ...
user avatar
1 vote
0 answers
47 views

pdflatex hangs when compiling some pdf files [closed]

I'm using TeXstudio an a Mac and have found that some pgf files (obtained from python's Matplotlib), cause the compilation to hang. Also, when I run pdflatex from the terminal, it hangs on: [13] (./...
user avatar
  • 193
0 votes
0 answers
830 views

Latex does not work in Python's matplotlib

I installed MikTex and try to plot some graphs using Matplotlib. There, I want to use Latex, but I get the following error: File "C:\Users\Leo\anaconda3\lib\site-packages\matplotlib\texmanager....
user avatar
1 vote
0 answers
81 views

Externalize PGF file that includes a cross-reference

I have some figures as PGF files that include cross-references in them. Each time I compile my main document, these figures are recompiled too. Therefore I would like to externalize these figures. The ...
user avatar
  • 11
1 vote
2 answers
574 views

What is the best way to include matplotlib plots?

I work on both Windows and Linux. I already include SVG graphics that I create in Inkscape with \usepackage{svg}. For maintainablitly reasons I would welcome to re-use that for matplotlib plots, but I ...
user avatar
1 vote
1 answer
200 views

Include “contour” package into matlplotlib and set title using it

I transfer the initial post from stackoverflow since one said it is rather a question for Tex exchange (I am going do delete the initial one). Here is this post : In a matplotlib script, I try to ...
user avatar
0 votes
0 answers
630 views

Formatting Matplotlib figure with subplots for Latex

I'm having trouble getting my plot to span the entire \textwidth. Here is an equivalent MWE of what I'm getting when I compile. Matplotlib code: (set_size is a function taken from here, but that doesn'...
user avatar
1 vote
1 answer
2k views

How to get Latex bold greek symbol with matplotlib for a title above a subplot [closed]

I have the following subplot (indexed by mand ngiven) : ax = g.subplots[m,n] I tried to set in bold Latex all the Latex expression $1 sigma \pm 0.1$. I have set up at the beginning of matplotlib ...
user avatar
0 votes
1 answer
99 views

Less xticks in pgfplots loglog

I use tikzplotlib to produce pfgplots figures from matplotlib. Here's the output I get trying to produces a loglog plot: Obviously there is something wrong with the x axis ticks. I would like to have ...
user avatar
0 votes
1 answer
314 views

Matplotlib PGF Export: Error Dimension too large

I have an issue I could not find any other threads on, only for people who create their pgf plot manually. I have created a boxplot using matplotlib and Seaborn. I want to export this plot to TeX, so ...
user avatar
  • 101
1 vote
1 answer
645 views

using plot with legend saved with tikzplotlib gives Error in latex

I am generating a plot with matplotlib and save it with tikzplotlib to use it later in latex. It works fine till the point where I use a legend in the plot. Then latex gives me the following Error ...
user avatar
0 votes
1 answer
54 views

Including .pgf plots with sans serif fonts in a serif document

I am creating the plots and figures for my thesis using matplotlib and save them as .pgf files that I include using \begin{figure} \input{myfigure.pgf} \caption{A caption} \end{figure} ...
user avatar
2 votes
2 answers
6k views

Can't save image as eps in matplotlib when using tex since new install

I want to save a plot from matplotlib as an eps file, which has worked previously with no problem. However, today I reinstalled latex and ever since, I have trouble with eps. I have the following MWE ...
user avatar
0 votes
1 answer
96 views

How to refer to non-existing subfigure?

I ploted a big figure with several subfigures in it using matplotlib, because the library provides many features that are difficult to implement in tex (like shared label and shared axis). However, I ...
user avatar
  • 101
0 votes
0 answers
58 views

Crop a pgf image to extents

I'm generating a fair bit of plots with matplotlib for my document. For consistent white space between plots, images, etc. I'd like to crop the plot images which are pgf to the extents of the plot "...
user avatar
1 vote
0 answers
1k views

PGF generated plot via Matplotlib and using relative font sizes when input to LaTeX

I can produce plots on matplotlib and export them to pgf successfully. But I believe that by first defining a base font size on matplotlib rcParams (11pt for example), and then defining things like ...
user avatar
0 votes
0 answers
432 views

How to force sans-serif fonts in matplotlib with xelatex PGF backend

This is a slightly borderline question for matplotlib-xelatex combination. I ma having an issue forcing a sans-serif font family in a png/pdf output of my matplotlib. I wanted to use tex rendering ...
user avatar
1 vote
0 answers
3k views

Including python matplotlib plots in LaTeX documents and inheriting document font properties

I am trying to get a standardised method to import plots from matplotlib into my LaTeX document, borrowing text formatting from the main document (so I want to avoid pure PDF). I am currently ...
user avatar
  • 11
1 vote
1 answer
445 views

Scale down the size of a PGF figure

I've created a plot using matplotlib in Python and saved it to a PGF which I've then embedded in my LaTeX document. I'd like it to be a bit smaller, as is it won't centre and it forces down a section'...
user avatar
2 votes
2 answers
8k views

Matplotlib error: No such file or directory: 'latex': 'latex'

I am running a public code downloaded from GitHub, but I have a problem when it gets to the end and it has to plot the results using LaTeX. I get the following error: FileNotFoundError: [Errno 2] ...
user avatar
1 vote
1 answer
462 views

Reference in latex document to part of Matplotlib (pgf) generated figure

I have a Python script which draws a plot similar to this: fig = plt.figure() ax = plt.axes() x = np.linspace(-2,2,10) y = x**2 ax.plot(x, y, label='$x^2$', color="#07529a", linewidth=2.0) # <--...
user avatar
1 vote
0 answers
938 views

How to include figures using Pythontex

I try the solution of G.Poore (https://github.com/gpoore/pythontex/wiki/matplotlib) in order to include easily a lot of figures in a TeX document using Pythontex. Unfortunately I get the following ...
user avatar
  • 693
2 votes
1 answer
2k views

The one of the Matploltlib example

import numpy as np import matplotlib matplotlib.rcParams['text.usetex'] = True import matplotlib.pyplot as plt t = np.linspace(0.0, 1.0, 100) s = np.cos(4 * np.pi * t) + 2 fig, ax = plt.subplots(...
user avatar
  • 21
4 votes
2 answers
295 views

How can I put a ring accent below (or inside) a letter in math mode?

I need to put a circle (ring, zero etc.) below or inside a \Lambda letter. I need to do so both in math mode of LaTeX document and in mathtext mode of matplotlib - so my choice of commands is limited....
user avatar
  • 205
2 votes
0 answers
367 views

LaTeX matplotlib pgf shows no colorbar - instead shows colorbar png image filename [duplicate]

Moved from Stack Overflow I'm producing various plots with matplotlib and save them as PGF files. These are then imported in my LaTeX file and compiled using the pgf package. The problem is, I can't ...
user avatar
0 votes
1 answer
2k views

Including a complex Matplotlib.Pytplot figure in Latex [duplicate]

I'm not sure if I should post this on the Python SE or here. I have made a complex figure in Python that is exactly how I want it to be. Now I want to include that figure in my thesis in LaTeX. As of ...
user avatar
  • 461
1 vote
1 answer
2k views

I do not know the key /tikz/none

I used matplotlib2tikz and now get the Package pgfkeys error: I do not know the key /tikz/none when I compile. I have \RequirePackage{pgfplots} and \RequirePackage[utf8]{inputenc} specified but it ...
user avatar
  • 125
2 votes
0 answers
835 views

Matplotlib PDF figures blurry when printed

I'm creating my figures with Matplotlib. They are in the standard pdf output format of Matplotlib and I include them with \includegraphics{figure.pdf}. In my python scripts I activated the usetex flag ...
user avatar
2 votes
1 answer
10k views

Matplotlib2tikz Increase spacing between ticks

I am using matplotlib2tikz to plot a barchart. However, the ticks are not spaced out enough. How do I increase the spacing between the results? My code: import matplotlib matplotlib.use("Agg") ...
user avatar
  • 21
0 votes
1 answer
675 views

Missing { inserted within matplotlib2tikz figure

After using matplotlib to create a bar chart, I use matplotlib2tikz to create a tikz figure. The code is as following: % This file was created by matplotlib2tikz v0.6.13. \begin{tikzpicture} \...
user avatar
7 votes
1 answer
7k views

How to use the \siunitx package within Python/matplotlib?

I'm writing a LaTeX document and I include some matplotlib plots in it, in .pgf format with \include{file.pgf}. It has advantages over exporting the matplotlib plot to .pdf or .eps formats in that the ...
user avatar
0 votes
0 answers
304 views

Eps figure shifted with XeTeX

I have an .eps figure which I produced with PyPlot (~matplotlib) in Julia. I have converted it to pdf with epstopdf fig.eps When I include it in a document it is shifted up- and rightwards. Minimal ...
user avatar
  • 135
2 votes
0 answers
1k views

Scaling PGF plots and its font independently

I am a PhD student, quite new to the fantastic LaTeX world. Although I have written sevral documents already, I am still a beginner, and definitely not a programmer. I am using Python for my research, ...
user avatar
2 votes
0 answers
1k views

Point to inch conversion different [duplicate]

I'm trying to plot a diagram with matplotlib and embed it in latex. I want the diagram to have the full textwidth so I printed the textwidth in points to my document with \the\textwidth. The value I'...
user avatar
1 vote
1 answer
519 views

How to display D-stroke symbol in matplotlib

I want to display the D-stroke symbol (\DJ) using the following code, but I failed. Could anyone tell me how to make it correct? As shown in the figure, the symbol $\mu$ works well but the $\DJ$ ...
user avatar
  • 11
1 vote
0 answers
8k views

Inserting and correctly scaling PGF figure made with matplotlib [duplicate]

I created a plot in matplotlib and saved it as a PGF file. I insert the figure into Latex with the following: \begin{figure} \centering \input{test_fig.pgf} \end{figure} With \usepackage{...
user avatar
  • 723