python Matplotlib旋转2d散点图90度

时间:2016-12-11 09:47:21

标签: python matplotlib plot rotation scatter-plot

我在python上使用matplotlib生成了一个二维散点图。

问题是整个数字旋转了90(与我想到的结果相比)..我需要将其旋转回来(即将整个数字旋转-90)

我查了一下,但我找不到与我需要做的相似的问题

以下是我绘制数据的代码部分

代码

#generate xvalues, yvalues and labels
x_list = [x for [x, y] in coordinates]
y_list = [y for [x, y] in coordinates]
#labels = ['point{0}'.format(i) for i in range(9)]
labels = ['c1', 'c2', 'c3', 'c4', 'c5', 'm1', 'm2', 'm3', 'm4']

#plt.plot(x_list, y_list,"ro")
#plt.margins(0.2)

#Generate scatter plot
T = np.arctan2(y_list,x_list)
originalplt = plt.scatter(x_list, y_list, s=75, c=T, alpha=.5)

#Annotate graph to points
for i in range(9):
    plt.annotate(
        labels[i], 
        xy = (x_list[i], y_list[i]), xytext = (-20, 20),
        textcoords = 'offset points', ha = 'right', va = 'bottom',
        bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),
        arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0'))

#Plot graph
plt.xlim(0.0,1.8), plt.xticks([])
plt.ylim(-2.0,0.5), plt.yticks([])

#show plot
plt.show()

0 个答案:

没有答案