size of the picture

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

size of the picture

vincent_mathoscope
hi
for the book iwrite i need fonts in size 10
i put this size to the fonts and the exported picture, when included in my
TeXmacs document without changing the size, present fonts that fits
approximatively to this size of 10
but my pictures are really to big ; if i reduce them (they are png) then of
course the fonts are reduced also
i have been searching on internet since 2 days, looking for the right
instruction to fix the size of the picture
i did not find my answer here :
https://stackoverflow.com/questions/8775622/exact-figure-size-in-matplotlib-with-title-axis-labels
<https://stackoverflow.com/questions/8775622/exact-figure-size-in-matplotlib-with-title-axis-labels>  
here the topic seemed to be mine :
http://scipy-cookbook.readthedocs.io/items/Matplotlib_AdjustingImageSize.html
<http://scipy-cookbook.readthedocs.io/items/Matplotlib_AdjustingImageSize.html>  
but this code, just copy-pasted from this link :

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

i am just missing this point to start working

thanks if you have ideas.



-----
        ––––––––––––––––––––––––––
                  Vincent Douce
               :=: Mathoscope :=:
             http://mathoscope.xyz
                 06°13°11°07°26
          Bagnères de Bigorre 65200
--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
        ––––––––––––––––––––––––––
                  Vincent Douce
               :=: Mathoscope :=:
             http://mathoscope.xyz
                 06°13°11°07°26
          Bagnères de Bigorre 65200
Reply | Threaded
Open this post in threaded view
|

Re: size of the picture

Jody Klymak

```python

fig, ax = plt.subplots(figsize=(5,3))

```

will give a figure that is 5 inches wide by 3 inches tall.  

Cheers,   Jody


> On Nov 29, 2017, at  22:18 PM, vincent_mathoscope <[hidden email]> wrote:
>
> hi
> for the book iwrite i need fonts in size 10
> i put this size to the fonts and the exported picture, when included in my
> TeXmacs document without changing the size, present fonts that fits
> approximatively to this size of 10
> but my pictures are really to big ; if i reduce them (they are png) then of
> course the fonts are reduced also
> i have been searching on internet since 2 days, looking for the right
> instruction to fix the size of the picture
> i did not find my answer here :
> https://stackoverflow.com/questions/8775622/exact-figure-size-in-matplotlib-with-title-axis-labels
> <https://stackoverflow.com/questions/8775622/exact-figure-size-in-matplotlib-with-title-axis-labels>  
> here the topic seemed to be mine :
> http://scipy-cookbook.readthedocs.io/items/Matplotlib_AdjustingImageSize.html
> <http://scipy-cookbook.readthedocs.io/items/Matplotlib_AdjustingImageSize.html>  
> but this code, just copy-pasted from this link :
>
> 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
>
> i am just missing this point to start working
>
> thanks if you have ideas.
>
>
>
> -----
>        ––––––––––––––––––––––––––
>                  Vincent Douce
>               :=: Mathoscope :=:
>             http://mathoscope.xyz
>                 06°13°11°07°26
>          Bagnères de Bigorre 65200
> --
> Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
> _______________________________________________
> Matplotlib-users mailing list
> [hidden email]
> https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: size of the picture

vincent_mathoscope
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



-----
        ––––––––––––––––––––––––––
                  Vincent Douce
               :=: Mathoscope :=:
             http://mathoscope.xyz
                 06°13°11°07°26
          Bagnères de Bigorre 65200
--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
        ––––––––––––––––––––––––––
                  Vincent Douce
               :=: Mathoscope :=:
             http://mathoscope.xyz
                 06°13°11°07°26
          Bagnères de Bigorre 65200
Reply | Threaded
Open this post in threaded view
|

Re: size of the picture

Adrien VINCENT
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. :).

```python
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")
```

If you have more general questions about the usage of Matplotlib, you
may also find some useful informations in
[here](https://matplotlib.org/tutorials/index.html)

Best regards,
Adrien

On 11/29/2017 10:40 PM, vincent_mathoscope wrote:

> 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
>
>
>
> -----
>          ––––––––––––––––––––––––––
>                    Vincent Douce
>                 :=: Mathoscope :=:
>               http://mathoscope.xyz
>                   06°13°11°07°26
>            Bagnères de Bigorre 65200
> --
> Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
> _______________________________________________
> Matplotlib-users mailing list
> [hidden email]
> https://mail.python.org/mailman/listinfo/matplotlib-users
>

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: size of the picture

Julian Gethmann
Hi Vincent,

To get to know the width in LaTeX you can use the commands
```LaTeX
\showthe\textwidth
```
or
```LaTeX
\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, [hidden email] 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. :).
>
> ```python
> 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")
> ```
>
> If you have more general questions about the usage of Matplotlib, you
> may also find some useful informations in
> [here](https://matplotlib.org/tutorials/index.html)
>
> Best regards,
> Adrien
>
> On 11/29/2017 10:40 PM, vincent_mathoscope wrote:
>> 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
>>
>>
>>
>> -----
>>          ––––––––––––––––––––––––––
>>                    Vincent Douce
>>                 :=: Mathoscope :=:
>>               http://mathoscope.xyz
>>                   06°13°11°07°26
>>            Bagnères de Bigorre 65200
>> --
>> Sent from:
>> http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
>> _______________________________________________
>> Matplotlib-users mailing list
>> [hidden email]
>> https://mail.python.org/mailman/listinfo/matplotlib-users
>>
>
> _______________________________________________
> Matplotlib-users mailing list
> [hidden email]
> https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: size of the picture

vincent_mathoscope
In reply to this post by vincent_mathoscope
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...



-----
        ––––––––––––––––––––––––––
                  Vincent Douce
               :=: Mathoscope :=:
             http://mathoscope.xyz
                 06°13°11°07°26
          Bagnères de Bigorre 65200
--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
        ––––––––––––––––––––––––––
                  Vincent Douce
               :=: Mathoscope :=:
             http://mathoscope.xyz
                 06°13°11°07°26
          Bagnères de Bigorre 65200