[英]matplotlib: Set width or height of figure without changing aspect ratio
[英]Python: set aspect ratio of figure to 1
如何獲得具有 1:1 縱橫比的圖形? 我目前有下圖
import matplotlib.pyplot as plt
circle1 = plt.Circle((0.5, 0.5), 0.2, color='r')
fig, ax = plt.subplots()
ax.add_artist(circle1)
但是 x 軸大於 y 軸。 我嘗試使用在這里找到的命令:
import matplotlib.pyplot as plt
circle1 = plt.Circle((0.5, 0.5), 0.2, color='r')
fig, ax = plt.subplots()
ax.add_artist(circle1)
plt.axes().set_aspect('equal', 'datalim')
但后來我畫的圓圈消失了。
如何設置相等的縱橫比?
將方面 kw 添加到您的 fig, ax 語句中:
fig, ax = plt.subplots(subplot_kw={'aspect': 1})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.