python-3.x - 如何在 matplotlib 子图中设置属性?
问题描述
我想在 matplotlib 中制作子图并设置不同的属性:但我有一个错误 'AxesSubplot' object has no attribute 'setp'
fig, ax = plt.subplots()
ax.axvline(x=654.31, linewidth=4, ls = '--', color = 'Gold' )
(markers, stemlines, baseline) = ax.stem(dfs.index, dfs.RTCM)
ax.setp(stemlines, linestyle="-", color="olive", linewidth=0.5 )
我找不到解决问题的方法。我将不胜感激。
解决方案
可以直接在stem函数中设置线条格式和颜色
ax.stem(dfs.index, dfs.RTCM, linefmt='C4-', markerfmt='D')
推荐阅读
- css - 覆盖网页的 CSS
- php - Laravel 分页:为什么有些页面返回未定义的偏移量:0?
- python - 从组合框中选择数据位
- terraform - 地形 | 从 Cloud SQL 检索(客户端密钥)证书
- swift - 如何等待递归直到函数完成执行
- python-3.x - 非递归最高效的 Big-O 置换算法 Python3(非内置)
- .htaccess - 将对不存在的文件的任何查询重定向到一个 php 文件
- ruby-on-rails - 嵌套关联 has_many;through 不更新 collection_check_boxes
- javascript - 样式化从索引文件导入的 React 组件时出错,但直接从组件文件导入时不会出错
- r - 如何在使用 ggplot 在 R 中具有单个数据点的同时在轴上显示刻度标签?