Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
1 vote
1 answer
35 views

pgf import in LaTeX not working due to matplotlib axes font

I was plotting as usual and then after saving one of my plots as a pgf and then compiling LaTeX it didn't work anymore. As far as I'm aware of, I didn't change anything it just so happen to top ...
L_physics's user avatar
0 votes
0 answers
25 views

Matplotlib - Latex Premable Package not loading

I want to use LaTeX in the x-label of a plot. I need the label to be \varepsilon with a subscript that is a smaller version of the \parallel symbol. This is what I have tried but it does not work, I ...
Euler_Salter's user avatar
0 votes
0 answers
87 views

Tikzplotlib not outputting Matplotlib's PyPlot colour bars

I'm trying to output contour plots made with PyPlot to Tikz using Tikzplotlib, but the color bars aren't appearing in the outputted TeX code. The contour plots themselves aren't appearing either ...
TheorVHP's user avatar
0 votes
1 answer
183 views

How to use Matplotlib plot markers in LaTex text

I want to use plot markers from Matplotlib in Latex. Especially I am looking for Latex equivalents of the symbols '1', '2', '3' and '4', as used for the 'two pairs' label in the plot. I already looked ...
scleronomic's user avatar
1 vote
0 answers
171 views

Change "contour filled" smooth interpolation scheme. And problem with multiple contour filled on same axis

In this post I would like to solve two "issues" concerning PGF. The first one is the fact that adding multiple contour filled on the same axis, is producing a separation line that I would ...
TOP1's user avatar
  • 11
0 votes
1 answer
1k views

Matplotlib and Latex with all bold

I used to render all my Matplotlib fonts with latex and bold as follows: plt.rc('font', family='serif',size=20) matplotlib.rc('text', usetex=True) matplotlib.rc('legend', fontsize=14) matplotlib....
diedro's user avatar
  • 179
1 vote
1 answer
788 views

Formating a scalebar with Latex in the title of a Matplotlib figure

I have an image in matplotlib, and I want to put a scalebar in the title using Latex syntax. Using the \vdash and \dashv commands I can get the ends of the scalebar, as can been seen in the Figure, ...
Martin Gardfjell's user avatar
0 votes
1 answer
108 views

PGF generated with matplotlib contourf produces artifacts in pdf

I generate a contourplot with matplotlib.pyplot.contourf that produces a nice preview image: But when I include the image into my document (using the exact same settings that I successfully employ ...
Dan Doe's user avatar
  • 111
0 votes
0 answers
42 views

Matplotlib PGF Greek Char

To include plots in Latex I use pythons matplotlib (v3.5.2). The plots are then exported as pgf so that they can be included in the latex document (with \input...). However, as soon as I use a Greek ...
binex6's user avatar
  • 17
1 vote
1 answer
1k views

Saving plots with a legend tikzplotlib gives an Error in latex

I'm getting an error when I generate a (line)plot with either matplotlib or Seaborn and save it with tikzplotlib to use it later in latex. Everything works until I add a legend to the plot. This ...
Alex Günsberg's user avatar
2 votes
0 answers
303 views

Reduce file size of imported graphics and their fonts

I am looking to reduce the file size of the final version of my thesis as much as possible without real hassle and any loss of quality. At the moment it is around 7 MB. I read much about it (...
ACCakut's user avatar
  • 31
2 votes
1 answer
496 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....
ck1987pd's user avatar
  • 145
1 vote
0 answers
351 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: ...
JANO's user avatar
  • 113
9 votes
0 answers
312 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 ...
TomVincentUK's user avatar
4 votes
1 answer
167 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 ...
fpavogt's user avatar
  • 211
3 votes
1 answer
172 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 ...
fpavogt's user avatar
  • 211
0 votes
0 answers
273 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 ...
Keith Sloan's user avatar
0 votes
2 answers
1k 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 ...
likethevegetable's user avatar
0 votes
0 answers
123 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 ...
Harper's user avatar
  • 133
3 votes
1 answer
1k 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 ...
Friki's user avatar
  • 33
1 vote
3 answers
2k 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....
Bax Menker's user avatar
1 vote
0 answers
609 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.
user12290's user avatar
  • 3,351
2 votes
1 answer
2k 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} },
nikita0509's user avatar
1 vote
0 answers
4k 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
116 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
119 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] (./...
rhz's user avatar
  • 215
0 votes
0 answers
2k 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....
LionCereals's user avatar
1 vote
0 answers
167 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 ...
Spinbar's user avatar
  • 11
7 votes
3 answers
11k 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 ...
Andreas Schuldei's user avatar
1 vote
1 answer
448 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
1k 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'...
madman_with_a_box's user avatar
1 vote
1 answer
5k 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
158 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
520 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 ...
Maxbit's user avatar
  • 101
2 votes
1 answer
2k 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 ...
C0deP0ntage's user avatar
0 votes
1 answer
127 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} ...
Jan Lukas Bosse's user avatar
4 votes
2 answers
11k 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 ...
Marc Frei's user avatar
0 votes
1 answer
307 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 ...
tigertang's user avatar
  • 101
0 votes
0 answers
104 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 "...
likethevegetable's user avatar
2 votes
0 answers
2k 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 ...
likethevegetable's user avatar
0 votes
0 answers
703 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 ...
Robert Manson-Sawko's user avatar
1 vote
1 answer
4k 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 ...
krg's user avatar
  • 111
2 votes
1 answer
890 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'...
Marvin GaTeX's user avatar
2 votes
2 answers
14k 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] ...
Morrone Marco's user avatar
1 vote
1 answer
814 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) # <--...
LatexUser12's user avatar
1 vote
0 answers
1k 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 ...
jowe_19's user avatar
  • 939
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(...
joshua's user avatar
  • 21
4 votes
2 answers
479 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....
abukaj's user avatar
  • 147
2 votes
0 answers
371 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 ...
Felix Henningsen's 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 ...
Hans's user avatar
  • 491