答案1
像这样吗?
代码(使坐标适应您的数据):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}
\filldraw[cyan!20](-1,1) rectangle (8,-5);
\node at (4,.5) (b) {\bfseries \large Visit to museums in 2022};
\node at (4,.1) (b) {\bfseries (in millions)};
\foreach \i/\t/\d in {1/Firt Item/5.5,2/Second Item/4.8,3/Third Item/3.7,4/Fourth Item/2.5}{%
\pgfmathsetmacro{\j}{100-10*\i};
\node[anchor=west] at (.1,-\i+.2) (a\i) {\bfseries \t};
\filldraw[blue!\j] (0,-.5-\i) rectangle (\d,-\i) node[pos=.5,white] () {\bfseries \d};
}
\end{tikzpicture}
\end{document}
答案2
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}
\filldraw[cyan!10](-1,2) rectangle (8,-8);
\node at (3.4,1.5) (b) {\bfseries \large Visit to museums in \color{blue}{2022} \color{black}{and} \color{red}{2021}};
\node at (3.4,1) (b) {\bfseries (in millions)};
\foreach \i/\t/\d/\dr in {1/Firt Item/5.5/3.5,2/Second Item/4.8/3.6,3/Third Item/3.7/3,4/Fourth Item/2.5/2}{%
\pgfmathsetmacro{\j}{100-10*\i};
\node[anchor=west,violet] at (.1,{-2*(\i-1)+.2}) (a\i) {\bfseries \t};
\filldraw[blue!\j] (0,{-.5-2*(\i-1)}) rectangle (\d,{-2*(\i-1)}) node[pos=.5,white] () {\bfseries \d};
\filldraw[red!\j] (0,{-1.2-2*(\i-1)}) rectangle (\dr,{-.7-2*(\i-1)}) node[pos=.5,white] () {\bfseries \dr};
}
\node[violet,rotate=90] at (-.5,-3) () {\Large \bfseries Events};
\node[violet] at (4,-7.8) () {\Large \bfseries Quantity};
\end{tikzpicture}
\end{document}
输出:
我用图表(比我的英语好)回答 js bibra,并代入 y 公式 \i=1,\i=2,...,\i=4: