Skip to main content

All Questions

Tagged with
0 votes
1 answer
77 views

Build a LaTeX label programmatically in matplotlib

I can render hardcoded LaTeX expressions in matplotlib labels, no problem: import matplotlib.pyplot as plt import numpy as np x = np.linspace(0., 2.* np.pi, 20) y = 2. * np.pi * np.stack((np.sin(x), ...
0 votes
3 answers
106 views

How to reference a previously created file name in savefig [duplicate]

I am fairly inexperienced with python but I have quite a lot of data (csv) that I need to process and plot in figures. My question is when using plt.savefig how would I reference the figure file name ...
1 vote
0 answers
209 views

Both latex and parameter values in python strings

I want to add a title to my plots (in matplotlib) which would display both parameters and their values, something like f"$\alpha$ = {present value of alpha}, $\beta$ = {present value of beta}&...
2 votes
1 answer
2k views

How to use Latex within an f-string expression in Matplotlib; no variables in equation

I'm trying to make a title for a plot, but the title includes a variable, which I'm inserting using an f-string, but it also includes a Latex expression. I either get an error that f-string ...
3 votes
1 answer
2k views

Seaborn a lower subscript with f-string

I'd like to plot a figure with lower subscript xticks using f-string not only one-digit case but also two-digit cases like L_1, L_2, ... L_10,L_11,... . How could I correct my code? import matplotlib....
0 votes
1 answer
268 views

In Matplotlob writing mathematical expressions with f-literals; how to deal with the raise to the power (^)

I want to display certain equations on a Matplotlob plot. Following Writing mathematical expressions with Matplotlob I wrote the following. The coefficients for the question are also only available at ...
0 votes
0 answers
76 views

Multiple dollar signs in my annotated string in matplotlib

I've searched all over and can't find a strait forward answer to this question. I tried ax.text as well instead of annotate and still couldn't get it to work. I simply want to print my string ...
3 votes
1 answer
876 views

f-string in yaxis.set_major_formatter

I have the following code: import pandas as pd from pandas import DataFrame as df import matplotlib from pandas_datareader import data as web import matplotlib.pyplot as plt import datetime import ...
0 votes
1 answer
1k views

How do I display LaTeX braces in a f-string in Matplotlib

I'm unable to get LaTeX braces to display in my Matplotlib figures when I create labels using f-strings. For example fig, ax = plt.subplots(1, 3, figsize=(12,4), sharey=True) fig.suptitle("$x_n = ...
0 votes
2 answers
2k views

What does the f do in plt.ylabel(f'g(x)')?

Firstly, import matplotlib.pyplot as plt import matplotlib In an elementary example on how to plot with matplotlib in our lecture I encountered the following line plt.ylabel(f'g(x)') What I have ...
29 votes
1 answer
30k views

How to display LaTeX f-strings in matplotlib [duplicate]

In Python 3.6, there is the new f-string to include variables in strings which is great, but how do you correctly apply these strings to get super or subscripts printed for matplotlib? (to actually ...