I have a scatterplot with about 280,000 points which displays quite nicely. However, I would like to dynamic labels to each point so that when I zoom into the graph enough I can see a bit of text on each point.
I've tried just using plt.annotate on every point, and on a smaller number of points
for index, row in points.iterrows():
plt.annotate(row[0], (row[1], row[2]))
#if index+1 %100 == 0:
# break
This causes the window to lag and not actually display anything rather than display labels. If I uncomment the break then I still have a rather laggy window with a large black clump of overlapping text. If the text could only be displayed under a certain level of magnification, or even scale to be an appropriate size at different levels of magnification that would be great!
I'm really open to any solutions to create a labeled scatter plot from my data.
I was able to plot everything nicely with plotly like this, using plotly's Scattergl to speed everything up.
import plotly as plotly
py = plotly.offline
import plotly.graph_objs as go
trace = go.Scattergl(
x = points['x'],
y = points['y'],
text = points['word'],
mode = 'markers',
marker = dict(
color = '#FFBAD2',
line = dict(width = 1)
)
)
data = [trace]
layout = plotly.graph_objs.Layout(hovermode='closest')
figure = plotly.graph_objs.Figure(data=data, layout=layout)
py.plot(figure)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.