我在Debian buster上使用python 2.7.14和matplotlib 2.1.1。我想创建一个倒置径向轴的极坐标图。我在径向轴上的值大多是负的,我想要在较高半径处绘制的较低值,因为它们代表更好的结果,反之亦然。另外,我想将坐标原点设置为定义的值。然而,matplotlib似乎通过定义第二个参数经历第一个参数的限制而导致问题。这个问题here和here存在一些解决方案(可能有点过时)。但是有一种更优雅的方式来反转轴吗?我的代码如下所示:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
angle = [-90.,-45.,-30.,-20.,-13.,-9.,-6.,-4.,-2.,-1.,0.,1.,2.,4.,6.,9.,13.,20.,30.,45.,90.]
tresh = [-16.1,-16.,-13.8,-12.4,-10.7,-9.4,-8.,-6.7,-6.,-6.5,-6.4,-6.7,-6.5,-7.4,-7.6,-10.1,-12.4,-14.3,-15.5,-16.9,-17.4]
arc = np.deg2rad(angle)
fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
ax.plot(arc,tresh)
ax.set_thetamin(-90)
ax.set_thetamax(90)
ax.set_theta_zero_location('N', offset=0)
ax.set_theta_direction(-1)
#ax.set_rorigin(-2)#This origin I want to set optionally.
ax.set_ylim(-18,-5)
#plt.show()
fig.savefig('test.png')
感谢您的帮助。