Ask Your Question
1

Formatting plot title

asked 2021-04-17 12:59:34 +0200

debojit2178 gravatar image

updated 2021-04-18 13:20:11 +0200

slelievre gravatar image

I am not able to find formatting options for title for plot. Here's the code,

p1 = plot(fresnel_sin(t), (t, -pi, pi), ticks=[pi/4,0.1], tick_formatter=[pi,None], legend_label=r'$f(x) = \int_0^x \sin(\frac{\pi t^2}{2})dt$', axes_labels=[r'$x$', r'$f(x)$'], axes_labels_size=1.5, title='Fresnel\'s sin', title_pos=(0.5,1.1))
p1.set_legend_options(back_color=(0.9,0.9,0.9), shadow=False, font_size=14, loc=(0,0.7))
p1.show()

The title font is relatively small, I am not able to change it without making it look displeasing. I've tried the following modification,

p1 = plot(fresnel_sin(t), (t, -pi, pi), ticks=[pi/4,0.1], tick_formatter=[pi,None], legend_label=r'$f(x) = \int_0^x \sin(\frac{\pi t^2}{2})dt$', axes_labels=[r'$x$', r'$f(x)$'], axes_labels_size=1.5)
p1.set_legend_options(back_color=(0.9,0.9,0.9), shadow=False, font_size=14, loc=(0,0.7))
p2 = text('Fresnel\'s sin ', (1.5, 0.9), fontsize=14, color='black')
p1 + p2

But it's not what I want. Using text doesn't seem to do it(or so I think). Need some help here :).

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2021-04-18 04:15:33 +0200

debojit2178 gravatar image

Restricting the y range using ymin or ymax does the trick while using text in 2d plots. Here's the code,

p1 = plot(fresnel_sin(t), (t, -pi, pi), ticks=[pi/4,0.1], tick_formatter=[pi,None], legend_label=r'$f(x) = \int_0^x \sin(\frac{\pi t^2}{2})dt$', axes_labels=[r'$x$', r'$f(x)$'], axes_labels_size=1.5, ymin=-0.7, ymax=0.8, fontsize=12)
p1.set_legend_options(back_color=(0.9,0.9,0.9), shadow=False, font_size=14, loc=(0,0.7))
p2 = text('Fresnel\'s sin ', (0, 1.1), fontsize=14, color='black')
p1 + p2

But there should be a more direct way of doing it like in matplotlib. One has the title attribute for the object p1, where one can configure the title by providing a fontdict.

edit flag offensive delete link more
1

answered 2021-04-17 16:56:47 +0200

slelievre gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-04-17 12:59:34 +0200

Seen: 509 times

Last updated: Apr 18 '21