python - 单图多行传递一组颜色?
问题描述
用一个plot
命令绘制两条线应该不容易?
import matplotlib.pyplot as plt
plt.plot([[1,2],[5,6]], c=['k','g'])
ValueError: Invalid RGBA argument
我只需要两条线,一条是黑色的,另一条是绿色的。这里发生了什么?
解决方案
您需要有 2 条线,而不是 2 个点来绘制 2 条线。
import matplotlib.pyplot as plt
plt.plot(x1, y1, c = 'k')
plt.plot(x2, y2, c = 'g') #x1, y1, x2, y2 should be multiple points
推荐阅读
- elasticsearch - 尝试为定义的 Elasticsearch 模板中缺少的字段建立索引
- php - 在 php 中注销时出现 500 内部服务器错误
- laravel - laravel 中的更新方法问题(不支持 POST 方法)
- angular - 如何获取打字稿对象的属性
- python - 在 .insert_picture() 之后访问 python-pptx 图片占位符时出错
- python - 如何将推荐 Keras 模型从 Tensorflow 示例导出到 tflite?
- reactjs - 使用 react-spring,如何在不提供“from”值的情况下使用“useSpring()”进行动画处理?
- java - 如何使用通用方法获取实例
- android - 如何在 android sharesheet 中显示应用程序的多个活动?
- javascript - obj1 在深度比较算法中未定义