psrqpy
psrqpy copied to clipboard
Add plotting functions
It would be good to have plotting functions to produce plots of one parameter vs another for any numerical parameters that had been queried.
In particular, for a start it would be nice to have a pvspdot function that automatically produces a P-Pdot diagram (this could include the pulsar death line, lines of characteristic age, lines of constant magnetic field, and it could have different markers for the different pulsar types).
It might be nice to add the ability to produce some of the nice plots that @astrophysically has in this notebook. Also, I could add the option to download the entire catalogue and return it as an astropy table, as in that notebook.
Things to do:
- add a
plot
method that takes in two parameter names and produces a scatter plot of those two parameters. If one or both parameters have not already been queried it could regenerate the query. It could also take in conditions for the plotted pulsars and show the various types using different markers. - add a
hist
method to produce 1D (or maybe also 2d) histograms of parameters. It could also include options to show a smoothed KDE of the parameters (or maybe even an IGMM estimate, or extreme deconvolution estimate) of the parameter. - allow the use of, e.g., the plot.ly interface to matplotlib to output interactive plots, with e.g. tool tips to show pulsar names, or parameter values, and allow zooming.
If I'm going to use plot.ly I think I may just have to re-create plots with the native Python interface rather than trying to use the matplotlib figure conversion tools, which don't support a lot of things yet (an maybe never will).
I could also consider using altair rather than plot.ly. It seems to have recently got tooltips in the implementation.
Get tool thanks! I have tried the ppdot plotting function (with the 3 lines from the documentation), no error message but no result neither. Shall it be embedded in matplotlib or other plotting library? Could you give a complete exemple?
Hi @jeromemargueron, thanks for your comment. Try doing:
from psrqpy import QueryATNF
query = QueryATNF(params=['P0', 'P1', 'ASSOC', 'BINARY', 'TYPE', 'P1_I'])
fig = query.ppdot(showSNRs=True, showtypes='all')
fig.show()
The figure may not display that well due to the high default DPI and size, so you could also try something like:
fig = query.ppdot(showSNRs=True, showtypes='all')
fig.set_figheight(9)
fig.set_figwidth(7)
fig.set_dpi(100)
fig.show()
Hope that helps.