Getting x,y values from seaborn relplot

With code I can plot starfields in size and color ,very good.
what I like to do now is, hovering or click on a star and then extra information from that star pops up.
to achieve this, I was thinking this way:
every time the code plots a star in the graphic there is information about the x,y value, catch this value in a dataframe together with the star ID. simple ? it isn’t.
this is a acutelly the code who does the plot work.

sns.relplot(x='ra', y='dec', height=8.5, aspect=1.2, legend=None,

So in the script this is a loop, so everytime the relplot plots new data on the graph (x,y) from the dataframe.
I like to catch these x,y values to store in a dataframe.

what i,m struggling with is how to get the seaborn relplot x,y values. so I can store them in a dataframe.

I searched and tried many lecture and code but I cant get these x,y values, maybe somebody has an Idea? or a better way?
thanks for answers.
with kind regards…


I’m not sure I quite understand the question, because for a scatterplot, the x/y values in the plot are just the x/y values in the data that you provide. Some of the other functions will do aggregations/transformations that it might be cumbersome to replicate externally, but it seems that you’re asking for a data structure that you already poseses.

You can accomplish some fairly complex custom interactivity using the matplotlib callback system, but I am not an expert on these tools and would struggle to provide an optimal example.

Michael , thanks for your reply, maybe youre right, but its a relplot not a scatter plot, the x,y data are
astronomical values, so there are not x,y values.
Its not clear for me how relplot plots the x,y coordinates in respect to the ra, dec values.
somehow relplot translate ra (27:40:12) value to a coordinate in the a x value, how to get that x value.


A relplot is just a scatterplot + FacetGrid. But I am afraid I don’t know anything about astronomical data and don’t understand why they would not be “x,y values” … I think you’ll need to provide more context about your dataset.

Michael, my dataset is huge…it looks leke this. small part…


are these 115.514662733389|, -14.8507044657302 the x,y values on the plot?

is there an onclick or hoover event in seaborn relplot?

Seaborn does not offer any additional features for interactivity, but because it’s all based on matplotlib, you can make the plots that seaborn produces interactive by using matplotlib tools. Depending on what exactly you’re trying to do, you may find that seaborn’s abstractions get in the way, and that it is simpler to build an interactive application just using matplotlib.

It’s hard to give a general suggestion because it will probably depend a bit on what exactly you’re trying to do and on your level of knowledge about the two libraries.

It would be easier to advise on your project if you could share a complete (i.e. runnable) example of how your data are structured and what you have done so far. You don’t need to share your complete dataset, just enough to demonstrate the basic functionality. There are some helpful guidelines on this page.

Michael, sorry for the late reply, busy on the house…I will look at your writing.