Any way to add figure string for subplots

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Any way to add figure string for subplots

谢瑾博
Dear Users,
I am trying to do a subplot consist of several axes like one below. My problem is that the small figure string for each subplot (a)(b)(c), if there is any resource controlling this text, or I have to some other configurations?
Jinbo



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

Re: Any way to add figure string for subplots

vincent.adrien@gmail.com
Hi Jinbo,

You should be able to achieve this with `annotate`. Here is a small
snippet demonstrating its basic use:
```python
import matplotlib.pyplot as plt
plt.ion()

fig, axs = plt.subplots(ncols=2, nrows=2)  # dummy 2x2 subplot grid

# NB: a better annotation tutorial is available at
# https://matplotlib.org/tutorials/text/annotations.html
for ax, label in zip(axs.flat, ["(a)", "(b)", "(c)", "(d)"]):
    ax.annotate(label,
                (0.02, 0.03), xycoords="axes fraction",  # coordinates
                ha="left", va="bottom",  # horiz. & vertical alignement
                weight="bold", style="italic"  # font option examples
                )
```

If you need to draw a white box behind the annotations, please have a
look at
https://matplotlib.org/tutorials/text/annotations.html#annotating-with-text-with-box

Hopefully this helps.

Best regards,
Adrien

Le 16/06/2019 à 10:47, 谢瑾博 a écrit :

> Dear Users,
> I am trying to do a subplot consist of several axes like one below. My
> problem is that the small figure string for each subplot (a)(b)(c), if
> there is any resource controlling this text, or I have to some other
> configurations?
> Jinbo
>
>
>
>
> _______________________________________________
> 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: Any way to add figure string for subplots

谢瑾博
Hi Vincent,
    Thanks, I have looked into this, and the labels works pretty fine!
         yours,
                Jinbo

> -----原始邮件-----
> 发件人: "[hidden email]" <[hidden email]>
> 发送时间: 2019-06-16 22:31:51 (星期日)
> 收件人: [hidden email]
> 抄送:
> 主题: Re: [Matplotlib-users] Any way to add figure string for subplots
>
> Hi Jinbo,
>
> You should be able to achieve this with `annotate`. Here is a small
> snippet demonstrating its basic use:
> ```python
> import matplotlib.pyplot as plt
> plt.ion()
>
> fig, axs = plt.subplots(ncols=2, nrows=2)  # dummy 2x2 subplot grid
>
> # NB: a better annotation tutorial is available at
> # https://matplotlib.org/tutorials/text/annotations.html
> for ax, label in zip(axs.flat, ["(a)", "(b)", "(c)", "(d)"]):
>     ax.annotate(label,
>                 (0.02, 0.03), xycoords="axes fraction",  # coordinates
>                 ha="left", va="bottom",  # horiz. & vertical alignement
>                 weight="bold", style="italic"  # font option examples
>                 )
> ```
>
> If you need to draw a white box behind the annotations, please have a
> look at
> https://matplotlib.org/tutorials/text/annotations.html#annotating-with-text-with-box
>
> Hopefully this helps.
>
> Best regards,
> Adrien
>
> Le 16/06/2019 à 10:47, 谢瑾博 a écrit :
> > Dear Users,
> > I am trying to do a subplot consist of several axes like one below. My
> > problem is that the small figure string for each subplot (a)(b)(c), if
> > there is any resource controlling this text, or I have to some other
> > configurations?
> > Jinbo
> >
> >
> >
> >
> > _______________________________________________
> > 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


--
Dr. Jinbo Xie
State Key Laboratory of Numerical Modeling for Atmospheric Sciences and Geophysical Fluid Dynamics (LASG)
Institute of Atmospheric Physics,Chinese Academy of Sciences
e-mail: [hidden email]
Tel:86-10-8299-5419(o)
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users