我正在尝试在极坐标中绘制一些数据,但我不想要使用 Matplotlib polar()
函数获得的标准刻度、标签、轴等。我想要的只是原始图,没有其他任何东西,因为我正在使用手动绘制的补丁和线条来处理所有内容。
以下是我考虑过的选项:
1)使用 polar()
绘制数据,隐藏多余的内容(使用 ax.axes.get_xaxis().set_visible(False)
> 等),然后绘制我自己的轴(使用 Line2D、Circle 等)。问题是,当我调用 polar()
并随后添加 Circle
补丁时,它是在极坐标中绘制的,最终看起来像一个无穷大符号。此外,缩放似乎不适用于 polar()
函数。
2)跳过polar()
函数并以某种方式使用Line2D手动制作我自己的极坐标图。问题是我不知道如何使 Line2D 在极坐标中绘制,并且还没有弄清楚如何使用变换来做到这一点。
知道我应该如何进行吗?
I'm trying to plot some data in polar coordinates, but I don't want the standard ticks, labels, axes, etc. that you get with the Matplotlib polar()
function. All I want is the raw plot and nothing else, as I'm handling everything with manually drawn patches and lines.
Here are the options I've considered:
1) Drawing the data with polar()
, hiding the superfluous stuff (with ax.axes.get_xaxis().set_visible(False)
, etc.) and then drawing my own axes (with Line2D
, Circle
, etc.). The problem is when I call polar()
and subsequently add a Circle
patch, it's drawn in polar coordinates and ends up looking like an infinity symbol. Also zooming doesn't seem to work with the polar()
function.
2) Skip the polar()
function and somehow make my own polar plot manually using Line2D. The problem is I don't know how to make Line2D draw in polar coordinates and haven't figured out how to use a transform to do that.
Any idea how I should proceed?
发布评论
评论(3)
考虑到您想要做什么,您的选项#2 可能是最简单的。因此,您将停留在直角坐标中,将函数从极坐标修改为直角坐标,并使用plot()绘制它(这比使用“Line2D”更容易)。
将极坐标函数转换为矩形函数可以通过以下方式完成:
绘图可以通过以下方式完成:
Your option #2 is probably the simplest, given what you want to do. You would thus stay in rectangular coordinates, modify your function from polar to rectangular coordinates, and plot it with
plot()
(which is easier than using `Line2D').The transformation of your polar function into a rectangular one can be done with:
and the plotting can be done with:
要删除刻度和标签,请尝试使用
From http://matplotlib。 sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.polar
To remove the ticks and the labels, try using
From http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.polar
关于您关于使用 matplotlib 变换的评论...我使用以下方法将极坐标图转换为可以在笛卡尔/矩形轴上绘制的多边形。
Regarding your comment about using the matplotlib transforms...I used the following method to translate a polar plot into a polygon that I could draw on my cartesian/rectangular axes.