gpt4 book ai didi

python - 定义椭圆的网格大小

转载 作者:行者123 更新时间:2023-11-30 22:15:06 25 4
gpt4 key购买 nike

我需要创建一个椭圆图。我的代码如下:-

import numpy as np
import pandas as pd
import math as m
import matplotlib.patches as patches
import matplotlib.pyplot as plt
x1=6.5 #Approach distane measurement point
y1=0.45 #Lateral distance measurement point
Nx=np.linspace(80,60,10)
Ny=np.linspace(80,60,10)
c=20
a=(10**(Nx/c))
b=(10**(86/20))
x=x1*(a/b) #semi major axis
Final_calculation=pd.DataFrame(x,columns = ["Distance_xaxis"])
a=(10**(Ny/c))
b=(10**(83/20))
y=y1*(a/b) #semi mionr axis
Final_calculation['Distance_yaxis']=y
Final_calculation['Sound unit decibel']=Nx
fig = plt.figure()
ax = fig.add_subplot(111, aspect='auto')
e1 = patches.Ellipse((0,0),x[0],y[0],linewidth=2, fill=False, zorder=2)
ax.add_patch(e1)

但是 python 显示的 x 和 y 轴值最多只能为 1。如何增加网格大小? as shown in figure

最佳答案

您可以使用 ax.autoscale 打开两个轴的自动缩放(而不是手动增加轴限制,这是一个选项) :

ax.autoscale(True)

你的代码变成

x1=6.5 #Approach distane measurement point
y1=0.45 #Lateral distance measurement point
Nx=np.linspace(80,60,10)
Ny=np.linspace(80,60,10)
c=20
a=(10**(Nx/c))
b=(10**(86/20))
x=x1*(a/b) #semi major axis
Final_calculation=pd.DataFrame(x,columns = ["Distance_xaxis"])
a=(10**(Ny/c))
b=(10**(83/20))
y=y1*(a/b) #semi mionr axis
Final_calculation['Distance_yaxis']=y
Final_calculation['Sound unit decibel']=Nx
fig = plt.figure()
ax = fig.add_subplot(111, aspect='auto')
e1 = patches.Ellipse((0,0),x[0],y[0],linewidth=2, fill=False, zorder=2)
ax.add_patch(e1)
ax.autoscale(True)
plt.show()

enter image description here

关于python - 定义椭圆的网格大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50368992/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com