python - 如何在matplotlib python上创建带有辅助y轴的分组条形图
问题描述
我刚开始学习和使用python。当我尝试使用辅助 y 轴创建分组条形图时遇到麻烦。
这是刚才的代码和结果
import matplotlib.pyplot as plt
fig, graph1=plt.subplots(figsize=(20,5))
graph2 = graph1.twinx()
graph1.bar(data_trans3['ITEM_NAME'],data_trans3['nett_profit'],width=0.3)
graph2.bar(data_trans3['ITEM_NAME'],data_trans3['QTY'],width=0.3)
我应该怎么做才能创建分组条形图,其中x 轴为item_name,y-primary 轴为nett_profit而y-secondary 轴为QTY。
我确信上面的代码是一个简单的条形图的形式。
解决方案
推荐阅读
- java - 在java中分隔一个字符串
- beautifulsoup - 使用 Python 进行网页抓取:BeautifulSoup 的问题
- php - 员工月休假报告
- javascript - array.map() 的意外结果
- flutter - Dart - 解析嵌套的 Json 数组
- node.js - 保存对话记录 - bot framework v4.4 node.js
- google-cloud-firestore - Datastore 模式下的新 Google Cloud Firestore 查询说明
- mongodb - 为什么 `mongoimport` 不能连接到我的免费层 MongoDB Atlas 集群?
- mongodb - 从匹配条件的数组中的对象中提取值
- angular - 忽略构建角度中的模板错误