Matplotlib with hl.plot

I am trying to use matplotlib to increase the aesthetics of the hail plots. Do you all have any recommendations on how to do so?

Hey genome,

You can’t use matplotlib to change plots generated by hl.plot. Those plots are generated by a library called bokeh, and so you’d have to use that library to make changes.

However, depending on what you’re trying to do, we have a newer plotting library that we added yesterday that is based on R’s ggplot. This library is much more flexible. It makes plotly plots, so also not matplotlib. Hail | Plotting With hail.ggplot Overview

What kind of plot are you trying to make?

I am trying to make histograms and scatterplots. I am also thinking if I am able to extract the data into a CSV file and then plot using matplotlib. I will check out the ggplot too!

Yeah, ok, so I think you’ll benefit a lot from the hl.ggplot module. To make a scatter plot, you can do like:

from hail.ggplot import *
my_plot = ggplot(my_table, aes(x=my_table.x_field_name, y=my_table.y_field_name)) + geom_point()

Where you have to fill in x_field_name and y_field_name. And there’s further room to customize point size, color, title, axis labels, etc.

Note that you have to update to hail 0.2.81 if you haven’t yet to get this working.

And yes, you could definitely output to CSV and use matplotlib if you were so inclined.

1 Like