gave this message :
AttributeError: 'Figure' object has no attribute 'set_figsize_inches'
of course i can fix the font to some random value say 24 and reduce the
picture to a random % and, by trials and approximations, find the right size
and the right % so that the text in my pictures seem to be 10
i'm sure it must exist a more satisfying way but can not find it
gave this message :
AttributeError: 'Figure' object has no attribute 'set_figsize_inches'
of course i can fix the font to some random value say 24 and reduce the
picture to a random % and, by trials and approximations, find the right size
and the right % so that the text in my pictures seem to be 10
i'm sure it must exist a more satisfying way but can not find it
thank you Jody
i tried quickly your code before going to work
this code :
just gave an empty picture with some graduations on the axes that were not
coded in my picture
if you have a cuple of seconds to explain a bit longer that will be useful
for me
otherwise i take time to look at it this evening
Here is a small snippet of code on the very same idea that Jody already
suggested, but this time with examples of texts, labels, etc. :).
import matplotlib.pyplot as plt
plt.ion() # if you do not want displaying of figures to be blocking
# Default cosmetick tweaks. Note than one could also define the default
# figure size, as well as the weight of the fonts, etc.
plt.style.use(["default"]) # reset: better safe than sorry
plt.rcParams["font.size"] = 10 # in points
plt.rcParams["axes.labelsize"] = 10 # in points
plt.rcParams["axes.titlesize"] = 10 # in points
# This is what you may looking for. Knowing the size of the figures
# that you produce, you should be able to ask LaTeX to use the exact
# same physical dimensions :).
width, height = (4, 3) # in inches (NB: 72 points per inch)
fig, ax = plt.subplots(figsize=(width, height))
# Dummy data (I was too lazy to import Numpy...)
x = [-1, 0, 1, 2]
y = [val**2 for val in x]
ax.plot(x, y, label="A line")
# Exercise most of the possible text of a plot
ax.set_xlabel("$x$")
ax.set_ylabel("$y = x^2$")
ax.set_title("A simple figure")
ax.legend()
fig.tight_layout() # to nicely fit the subplot(s) in the figure
# Record the figure in the format that you prefer
fig.savefig("my_figure.png", dpi=600)
fig.savefig("my_figure.pdf")
thank you Jody
i tried quickly your code before going to work
this code :
just gave an empty picture with some graduations on the axes that were not
coded in my picture
if you have a cuple of seconds to explain a bit longer that will be useful
for me
otherwise i take time to look at it this evening
To get to know the width in LaTeX you can use the commands
\showthe\textwidth
or
\showthe\columnwidth
which show you the value you then divide by 72 to get the value you want
to take for the width in Adrien's answer.
Best regards,
Julian
···
On 11/30/2017 08:42 AM, vincent.adrien at gmail.com wrote:
Hi Vincent,
Here is a small snippet of code on the very same idea that Jody already
suggested, but this time with examples of texts, labels, etc. :).
import matplotlib.pyplot as plt
plt.ion()? # if you do not want displaying of figures to be blocking
# Default cosmetick tweaks. Note than one could also define the default
# figure size, as well as the weight of the fonts, etc.
plt.style.use(["default"])? # reset: better safe than sorry
plt.rcParams["font.size"] = 10? # in points
plt.rcParams["axes.labelsize"] = 10? # in points
plt.rcParams["axes.titlesize"] = 10? # in points
# This is what you may looking for. Knowing the size of the figures
# that you produce, you should be able to ask LaTeX to use the exact
# same physical dimensions :).
width, height = (4, 3)? # in inches (NB: 72 points per inch)
fig, ax = plt.subplots(figsize=(width, height))
# Dummy data (I was too lazy to import Numpy...)
x = [-1, 0, 1, 2]
y = [val**2 for val in x]
ax.plot(x, y, label="A line")
# Exercise most of the possible text of a plot
ax.set_xlabel("$x$")
ax.set_ylabel("$y = x^2$")
ax.set_title("A simple figure")
ax.legend()
fig.tight_layout()? # to nicely fit the subplot(s) in the figure
# Record the figure in the format that you prefer
fig.savefig("my_figure.png", dpi=600)
fig.savefig("my_figure.pdf")
thank you Jody
i tried quickly your code before going to work
this code :
just gave an empty picture with some graduations on the axes that were
not
coded in my picture
if you have a cuple of seconds to explain a bit longer that will be
useful
for me
otherwise i take time to look at it this evening
hi Jody, Adrian, Julian
thanks for your detailed answers
i have spent a long time because i did not understand this point :
i had to cancel
plt.plot(X, C, color="blue", linewidth=1.0, linestyle="-")
and to replace it with
ax.plot(X, C, color="blue", linewidth=1.0, linestyle="-")
now, i have undesrtand this point and everything is ok
thanks...