import plotly.graph_objs as go

# 定义x轴数据
x = list(range(-10, 11))

# 定义y轴数据
y = [3 * i ** 2 for i in x]

# 创建trace
trace = go.Scatter(
    x=x,
    y=y,
    mode='lines',
    line=dict(width=2, color='blue')
)

# 创建布局
layout = go.Layout(
    width=600,
    height=600,
    xaxis=dict(title='空气流量q'),
    yaxis=dict(title='压力p')
)

# 创建figure
fig = go.Figure(data=[trace], layout=layout)

# 保存为svg格式
fig.write_image('curve.svg')

运行后会生成一个名为curve.svg的文件,保存着绘制的曲线。

使用plotly绘制y=3x^2的曲线图片尺寸为600X600pxX轴名称空气流量qY轴名称压力p使用figwrite_image保存曲线为svg格式

原文地址: http://www.cveoy.top/t/topic/begW 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录