简体   繁体   中英

Plot marker at one point instead of start and end point in Python matplotlib

I have a graph made up of lines with markers, however, I'm getting something that looks like this: 在此输入图像描述

I was wondering if there was a was to get the marker plotted at only the start point of the line rather than both the start and the end?

I can't seem to find anything on this anywhere so hopefully someone can help me!! Thanks in advance!

Perhaps not the prettiest solution, but it works; simply set markevery to a number equal to or larger than the array length:

import numpy as np
import matplotlib.pylab as pl

x = np.arange(10)
y = np.random.random(10)

pl.figure()
pl.subplot(121)
pl.plot(x, y, '-o', markersize=30)
pl.subplot(122)
pl.plot(x, y, '-o', markersize=30, markevery=x.size)

在此输入图像描述

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