首页 > 解决方案 > Edit marker shape in python

问题描述

I'm using diamond pointer on the x-axis of a CDF plot to show the distribution of some data. As the number of data is high, these points are close together and not distinguishable. I was wondering if there is a way to make the diamond marker for scatter plot more pointy.

enter image description here

标签: pythonmatplotlibscatter-plot

解决方案


You can define your own markers from a path, see the Marker Path Example.

import matplotlib.pyplot as plt
import matplotlib.path as mpath

pointed_diamond = mpath.Path([[0,-.5],[-.1,0],[0,.5],[.1,0],[0,-.5]], [1,2,2,2,79])
plt.plot([1,2,3], marker=pointed_diamond, markersize=10)

enter image description here


推荐阅读