python - 包含绘图设置的 matplotlib 字典
问题描述
我正在开发一个类以生成适合我的 pourpose 的情节......我第一次定义*args
要以简单的方式传递给类 =
attribute = [*args]
for in in range(len(attribute)):
plot(attribute[i],attribute[i+1], attribute[i+3])
哪里args
是包含 vector1, vector2, label='for the legend' 的列表
现在我意识到有时我需要传递给我的类 stype 的 plot 方法,更多的参数然后只是一个标签 .. 例如标记,特定的颜色......线宽,所以我认为作为三分之二传递 - th 参数以这种方式解包的字典:
for i in range(0,len(self.variable)-1,3):
plt.plot(self.variable[i],self.variable[i+1],self.variable[i+2])
但我真的不知道如何通过这本字典..我尝试:
fig1.plot(fet,feu[:,0],{ 'label' : 'Explicit Euler', 'linetype' :'-'},bet,beu[:,0],'Implicit Euler', {}, cnt,cnu[:,0], { 'label' : 'Crank-Nicholson'} )
编辑谢谢大家,但我解决了:
for i in range(0,len(self.variable)-1,3):
plt.plot(self.variable[i],self.variable[i+1],**self.variable[i+2], linewidth=3)
解决方案
推荐阅读
- cplex - 获取探查器错误 i CPLEX OPL - 发生溢出
- python - Python Selenium - 使用 Internet Explorer 发送密钥
- gitlab - 如何设置 Markdown 表格列的最小宽度?
- python - 使用 Python 优化以分数为约束的线性规划问题
- c++ - 类成员函数指针...我的代码对吗?
- python - Django 无法加载 psycopg2 模块。Python 也无法加载它,即使我在运行 pip list 时看到它
- android-intent - 我想启动录音机,但没有找到处理 Intent 的活动
- influxdb - 使用 1.x 客户端写入 InfluxDB 2.x
- domain-driven-design - 反应式编程和事件驱动架构的学习路径问题
- python - 如果列表中包含该字符串,则将列表中的字符串替换为另一个列表中的字符串(在 Python 中)