First time here? Check out the FAQ!

Ask Your Question
1

Formatting plot title

asked 4 years ago

debojit2178 gravatar image

updated 4 years ago

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

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 4 years ago

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.

Preview: (hide)
link
1

answered 4 years ago

slelievre gravatar image
Preview: (hide)
link

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: 4 years ago

Seen: 1,044 times

Last updated: Apr 18 '21