Mar*_* GN 1 matplotlib plotly-python
我想使用 Plotly express 绘制一些坐标,因为它允许我采用更具交互性的方法,但我找不到以单行中使用 matplotlib.pyplot 进行管理的方式来控制轴中的比例的方法
plt.axis("scaled")
Run Code Online (Sandbox Code Playgroud)
您能分享一些建议吗?谢谢。
这是使用 Plotly Express 的代码:
fig = px.scatter(coordinates_utm, x='EASTING', y='NORTHING', title=name,
hover_name=coordinates_utm.index,
hover_data={'NORTHING':':.6f','EASTING': ':.6f'})
fig.add_trace(px.scatter(coordinates_utm_lineal, x='x', y='ylineal',color_discrete_sequence=['red']).data[0])
Run Code Online (Sandbox Code Playgroud)
这是使用 plt 的代码:
fig.show()
plt.figure()
plt.scatter(coordinates_utm_lineal.x,coordinates_utm_lineal.ylineal,s=2)
plt.scatter(coordinates_utm.EASTING,coordinates_utm.NORTHING, s=2)
plt.axis("scaled")
plt.show()
Run Code Online (Sandbox Code Playgroud)
遗憾的是,您没有提供完全可重现的示例,因此我将创建自己的示例。
另外,我不太熟悉plt.axis("scaled")我通常使用的plt.axis("equal"). 阅读与 相关的文档plt.axis,它们似乎有些相似。看看下面的回答能否满足您的需求。
import plotly.express as px
import numpy as np
t = np.linspace(0, 2*np.pi)
x = np.cos(t)
y = np.sin(t)
fig = px.scatter(x=x, y=y)
fig.layout.yaxis.scaleanchor="x"
fig.show()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1744 次 |
| 最近记录: |