簡體   English   中英

Matplotlib 繪制 2 個圖形:1 個在極坐標中,1 個在笛卡爾坐標中

[英]Matplotlib graphing 2 graphs: 1 in polar and 1 in cartesian

我想繪制 2 個圖(水平),我希望一個是極坐標圖,另一個是笛卡爾圖。 我有以下代碼生成 2 個笛卡爾圖:

x = [1,2,3]
y = [1,2,3]
a = [2,3,4]
b = [5,7,5]

fig, (ax1,ax2) = plt.subplots(ncols = 2)
ax1.scatter(x,y)
ax2.scatter(a,b)
plt.show()

請注意,這些只是我選擇的隨機點。 我如何指定我想要的,比如 xy 圖,是極坐標的?

遺憾的是,無法將現有軸上的投影更改為極坐標,但您可以這樣做

import matplotlib.pyplot as plt

x = [1,2,3]
y = [1,2,3]
a = [2,3,4]
b = [5,7,5]

fig = plt.figure()
ax1 = plt.subplot(121)
ax2 = plt.subplot(122, projection='polar')

ax1.scatter(x,y)
ax2.scatter(a,b)
plt.show()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM