📚 The CoCalc Library - books, templates and other resources
License: OTHER
% Source: http://tex.stackexchange.com/a/69234/56451\documentclass[varwidth=true, border=2pt]{standalone}23\usepackage{pgfplots}4\usepackage{tikz}5\usetikzlibrary{arrows, positioning, calc}67\begin{document}8\newcommand\shift{1.5}910\begin{tikzpicture}[scale=1]11\begin{axis}[12ybar,13ylabel={vaule},14ylabel style={at={(0.02,0.5)}, color=red},15xlabel={items},16legend style={at={(0.5,-0.15)},17anchor=north,legend columns=-1},18width=0.8*\textwidth,19height=9cm,20bar width=7pt,21symbolic x coords={22$x_1$,$x_2$,$x_3$,$x_4$,$x_5$,$x_6$, $x_7$, $x_8$,23$x_9$, $x_{10}$, $x_{11}$, $x_{12}$, $x_{13}$,24$x_{14}$, $x_{15}$25},26xtick=data,27scaled y ticks=base 10:-3,28axis y line*=left,29%nodes near coords,30%nodes near coords align={vertical},31]32\addplot[red, fill=red!15, shift={(-\shift,0)}] coordinates {33($x_1$,96000) ($x_2$,126000) ($x_3$,115000)34($x_4$,125000) ($x_5$,123000) ($x_6$, 123000)35($x_7$, 112000) ($x_8$, 111000) ($x_9$, 110000)36($x_{10}$, 110000) ($x_{11}$, 120000)37($x_{12}$, 98000) ($x_{13}$, 130000)38($x_{14}$, 87000) ($x_{15}$, 97000)};39\end{axis}40\begin{axis}[41ybar,42ylabel={weight},43ylabel style={at={(1.25,0.5)}, color=blue},44legend style={at={(0.7,-0.15)},45anchor=north,legend columns=-1},46width=0.8*\textwidth,47height=9cm,48bar width=7pt,49symbolic x coords={50$x_1$,$x_2$,$x_3$,$x_4$,$x_5$,$x_6$, $x_7$, $x_8$,51$x_9$, $x_{10}$, $x_{11}$, $x_{12}$, $x_{13}$,52$x_{14}$, $x_{15}$53},54xtick=data,55%nodes near coords,56%nodes near coords align={vertical},57axis y line*=right,58axis x line=none,59]60\addplot +[shift={(\shift,0)}] coordinates {($x_1$,27)61($x_2$,21) ($x_3$,27) ($x_4$,15) ($x_5$,19)62($x_6$, 46) ($x_7$, 47) ($x_8$, 32) ($x_9$, 14)63($x_{10}$, 20) ($x_{11}$, 50) ($x_{12}$, 19)64($x_{13}$, 22) ($x_{14}$, 50) ($x_{15}$, 46)};65\end{axis}66\end{tikzpicture}67\end{document}686970