我需要散点画一本字典。在
我的数据如下:
{'+C': {1: 191, 2: 557}, '+B': None, '-B': None, '+D': None, '+N': {1: 1, 3: 1}, '+L': {1: 2819, 2: 1506}, '>L': None, '<C': {0: 2125}, '<B': None, '<L': {0: 2949, 1: 2062}}
外部关键点是x轴标签,内侧关键点是y轴。内部键的值是x,y的注释。我试着绘制数据,但是没有得到我想要的图形。在
我尝试了以下方法,但最终在x轴上重复了几次。在
^{pr2}$
您需要为x设置整数类别,然后可以在x轴上分配标签。下面的代码使用您dict中的操作代码。注意,python中的字典是无序的,因此需要对键进行排序。您可以改为使用有序dict,然后使用数字键()直接。在
每个点的注释都是字符串,每次放置一个,并在绘图上添加文本注释。我们需要用plt.轴()因为自动计算范围时不包括注释。在
有关散点图标记的不同方法,请参见以下问题:
Matplotlib: How to put individual tags for a scatter plot
相关问题 更多 >
编程相关推荐