change colorbar tick and label sizes in display.plot

743 views
Skip to first unread message

Anna del Moral

unread,
Aug 4, 2022, 5:14:24 AM8/4/22
to Py-ART Users
Hello,
I am trying to change the size of the colorbar for a psi cross section using radar.display, and I am having troubles trying to do so. I would appreciate any type of help. I have tried to set it with plt.colorbar and fig.colorbar, and I have error messages.
This is the code:
xsect = pyart.util.cross_section_ppi(radar, [320])
display = pyart.graph.RadarDisplay(xsect)
fig= plt.figure(figsize=(30,30))
ax1 = fig.add_subplot(311)
display.plot('DBZH',0, cmap='pyart_Carbone42', vmin=-5, vmax=65, ax=ax1,colorbar_label= 'DBZH [dBZ]',title=" ")
ax1.set_ylim([0, 14])
ax1.set_xlim([60, 100])
ax1.set_xlabel('', fontsize=24)
ax1.set_ylabel('Distance above radar [km]', fontsize=24)
plt.xticks(fontsize=20)
plt.yticks(fontsize=20)
ax2 = fig.add_subplot(312)
display.plot('VELH',0, cmap='pyart_Carbone42', vmin=-30, vmax=30,ax=ax2,colorbar_label= 'VELH [m/s]',title=" ")
ax2.set_ylim([0, 14])
ax2.set_xlim([60, 100])
ax2.set_xlabel('', fontsize=24)
ax2.set_ylabel('Distance above radar [km]', fontsize=24)
plt.xticks(fontsize=20)
plt.yticks(fontsize=20)
ax3 = fig.add_subplot(313)
display.plot('ZDR', 0,cmap=mymap, vmin=-5, vmax=5,ax=ax3,colorbar_label= 'ZDR [dB]',title=" ")
ax3.set_ylim([0, 14])
ax3.set_xlim([60, 100])
ax3.set_xlabel('Distance from radar [km]', fontsize=24)
ax3.set_ylabel('Distance above radar [km]', fontsize=24)
plt.xticks(fontsize=20)
plt.yticks(fontsize=20)
#plt.colorbar(fig,shrink=1.5)
#plt.tight_layout()
plt.show()

Thanks in advance!
Anna

Screen Shot 2022-08-04 at 03.07.36.png

sherma...@gmail.com

unread,
Aug 4, 2022, 10:38:40 AM8/4/22
to Py-ART Users
Hi Anna,

Can you trying calling colorbar from fig instead of plt and each colorbar define your cax parameter in the colorbar with each ax plot.

Then you should be able to adjust etc from there

Cheers,
Zach S.

Anna del Moral

unread,
Aug 4, 2022, 11:16:55 AM8/4/22
to Py-ART Users
Hi Zach, 
I tried calling colorbar from fig and plt, and it did not work.
However, a colleague also in this list helped me to solve the problem (Thanks Ludovico!).
Here is what we need to add:

display.cbs[i].ax.tick_params(labelsize=12)
display.cbs[i].set_label(label='ZDR [dB]',size=15) 

'i'=number of subplots we have.

Anna

Maxwell Grover

unread,
Aug 5, 2022, 4:40:43 PM8/5/22
to Py-ART Users
Hi Anna,

I am glad you were able to figure out a solution - here is another example of adding custom tick labels and label sizes https://arm-development.github.io/sail-xprecip-radar/radar-precip/plot-method-description-figure.html#plot-the-reflectivity-with-the-pluvio-sensor-and-watershed-locations

For future questions, please make sure to check out our question and answer part of Github Discussions (https://github.com/ARM-DOE/pyart/discussions/categories/q-a).

Thanks,

Max

Anna del Moral Mendez

unread,
Aug 6, 2022, 6:19:48 AM8/6/22
to Maxwell Grover, Py-ART Users
Hi Maxwell,

Thanks for pointing out those resources! Those are great.

Anna
--
You received this message because you are subscribed to a topic in the Google Groups "Py-ART Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyart-users/eg00Fr79Tk4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyart-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyart-users/f3774c9f-448b-42df-8edf-982a4d2b02acn%40googlegroups.com.


--
Anna del Moral Méndez, Ph.D.
Postdoctoral Fellow I
Advanced Study Program
National Center for Atmospheric Research

My working day may not be your working day. Please do not feel obliged to reply to this email outside of your normal working hours.



Reply all
Reply to author
Forward
0 new messages