latex - 创建条形图,条形总和高达 100
问题描述
我尝试使用 PGFPLOTS 在 LaTeX 中创建一个条形图,其中条形的总和为 100%。
下半部分(比如说 30%)应该是绿色的。
中间部分(比如说 20%)应该是黄色的。
上半部分(比如说 50%)应该是红色的。
我可以用这些数字并排生成图,但不能堆叠。
有人知道如何解决这个问题吗?
提前致谢!
解决方案
答案在“4.5.9 Stacked Plots”中的 pgfplots 手册中。(感谢@samcarter_is_at_topanswers.xyz 的提示)
我在本手册章节中使用的代码是这样的:
\begin{tikzpicture}
\begin{axis}[ybar stacked]
\addplotcoordinates{(0,1) (1,1) (2,3) (3,2) (4,1.5)};
\addplotcoordinates{(0,1) (1,1) (2,3) (3,2) (4,1.5)};
\addplotcoordinates{(0,1) (1,1) (2,3) (3,2) (4,1.5)};
\end{axis}
\end{tikzpicture}
推荐阅读
- sql - 选择人员及其多个字母 ID?
- html - 无法在 Angula6 的 HTML 页面上预先选择 mat 单选按钮
- sql - 如何在 SQL Server 中将日期时间值插入为 dd-mmm-yyyy hh:mm:ss AM/PM 格式
- rust - rust-如何将此marco与循环/递归结合起来?
- java - 易碎的普罗米修斯 java 客户端
- reactjs - React Hooks Dependencies - Infinite Loop
- git - How to list deleted github branches
- mongodb - 没有特定对象的过滤器数组
- vbscript - 如何使用 vbscript 和 UFT 将多个参数传递给 SystemUtil.Run?
- java - Springboot 无法将属性文件映射到变量