我希望你们都很好
我正在尝试使用 aspect_ratio=1 (两个轴的比例相同)进行绘图,但这总是给出一个平方布局,不管我正在绘制的元素的真正限制是什么
from bqplot import pyplot as plt
from bqplot import LinearScale, Axis, Lines, Figure
from ipywidgets import HTML
import pandas as pd
sc = LinearScale()
axis=[Axis(scale=sc,grid_lines='dashed'),
Axis(scale=sc,grid_lines='dashed', orientation='vertical')]
data = {
"X": [[0,2,5],[0,2,0]],
"Y": [[0,2,0],[0,2,2]],
"ID": ["1","2"],
"Material": ["clay","sand"],
"stress": [123, 234],
"strain": [0.123, 0.234],
"color": ['skyblue','pink']
}
df = pd.DataFrame(data)
def show_data(chart, d):
idx = d["data"]["index"]
df2=df.drop(columns=['X', 'Y','ID'])
table=pd.DataFrame(df2.iloc[idx])
elems.tooltip = HTML(table.to_html())
fig = plt.figure(axes=axis,min_aspect_ratio=1,max_aspect_ratio=1)
elems=plt.plot(x=df["X"].tolist(),
y=df["Y"].tolist(),
fill_colors=df["color"].tolist(),
fill='inside',
stroke_width=1,
close_path=True,
scales={'x': sc, 'y': sc})
elems.on_hover(show_data)
fig.layout.height = '720px'
# plt.ylim(0,2)
plt.show()
这是 bqplot 限制吗?下面我展示了我所拥有的和我想要的