简体   繁体   中英

How to add a marker in a specific point in a seaborn lineplot?

I'm plotting a simple lineplot with seaborn and I'd like to add a marker in two specific points of the lineplot.

I checked the documentation, and I know that matplotlib has some markers support ( https://matplotlib.org/3.1.0/api/markers_api.html ), but I couldn't find a solution for my problem.

I have something like this:

sns.lineplot(x="time", y="cost",
                   data=df_time)

I'd want to specify the plot to have a marker at both the rows n1 and n2. Is that possible?

The show a marker of the first and second point of a line plot use the markevery argument .

import matplotlib.pyplot as plt

x = [1,3,4,6,7,9]
y = [3,2,3,1,3,2]

plt.plot(x,y, marker="s", ms=12, markevery=[0,1])

plt.show()

在此处输入图片说明

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM