我有一个对数图,其\datavisualization
图形设置简化了,所以周围没有轴。我已经按照我想要的方式很好地设置了它。现在我想添加一些只围绕实际路径的网格线,即每个功率步骤的 ±3 x 单位。我可以手动让它工作,但它看起来很丑陋,我必须手动调整所有 33 个图的位置。我的第一个想法是使用交集库,但我无法将绘图输出作为路径抓取。除非我将其放入绘图中,name path
否则会抛出错误,但我无法访问它。style
从那时起,我放弃了,并决定只对clip
整个图表进行研究,结果发现datavisualization
忽略了clip
。
我的裸情节如下:
\documentclass{minimal}
\usepackage{tikz,pgf}
\usetikzlibrary{datavisualization,intersections}
\usepackage{filecontents}
\begin{filecontents}{China_GDPpP.csv}%Cut to keep it shorter
Year,Beijing
2014,99120
2010,71934
2009,65338
2008,62761
2005,45315
2000,23179
1995,12690
1990,4635
1985,2643
1980,1544
1978,1257
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\datavisualization[
new Cartesian axis=x axis, x axis={attribute=Year},
new Cartesian axis= y axis, y axis={attribute=Beijing}, %call specific column in a multi-column file
x axis={scaling=1978 at 0cm and 2015 at 5cm, unit vector={(1pt,0)}},
y axis={logarithmic,scaling=1000 at 0cm and 100000 at 3cm,unit vector={(90:1pt)}}
visualize as line=GDPpP, GDPpP={style={color=blue}}]
data [set=GDPpP,read from file=data/China_GDPpP.csv];
\end{tikzpicture}
\end{document}
由于我通过 调用不同的列y axis={attribute={}}
,因此我设置了第二个轴u axis
,该轴将在所有 33 个图表中保持不变。这还包含图表开头和结尾处的节点,指示y axis
该点的值。
\documentclass{minimal}
\usepackage{tikz,pgf}
\usetikzlibrary{datavisualization,intersections}
\usepackage{filecontents}
\begin{filecontents}{China_GDPpP.csv}%Cut to keep it shorter
Year,Beijing
2014,99120
2010,71934
2009,65338
2008,62761
2005,45315
2000,23179
1995,12690
1990,4635
1985,2643
1980,1544
1978,1257
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\datavisualization[
new Cartesian axis=x axis, x axis={attribute=Year},
new Cartesian axis= y axis, y axis={attribute=Beijing}, %call specific column in a multi-column file
new Cartesian axis=u axis, u axis={attribute=help},
x axis={scaling=1978 at 0cm and 2015 at 5cm, unit vector={(1pt,0)}},
y axis={logarithmic,scaling=1000 at 0cm and 100000 at 3cm,unit vector={(0,1pt)}},
u axis={logarithmic,scaling=1000 at 0cm and 100000 at 3cm,unit vector={(90:1pt)}},
visualize as line=helplines,helplines={style={gray!30}},
visualize as line=mainhelplines,mainhelplines={style={gray!50}},
visualize as line=GDPpP, GDPpP={style={blue,name path=datacurve}}]
data [set=mainhelplines]{
Year, help
1979, 1000} %provide one data point to ensure the u axis is drawn
data [set=GDPpP,read from file=data/China_GDPpP.csv]
info{%
\path[name path=line1000] (visualization cs: Year=1978, help=1000) -- (visualization cs: Year=2015,help=1000);
\draw[name intersections={of=datacurve and line1000}] [shift={visualization cs: Year=-3,help=0}] (intersection-1) -- [shift={visualization cs: Year=+3,help=0}] (intersection-1);} %info allows accessing the visualization cs:
\draw [gray] (visualization cs: Year=1978,help=1000) node[left,font=\scriptsize]{1000} (visualization cs: Year=2015,help=100000) node[right,font=\scriptsize]{100000};}; %This works without problem, provided the single data point is there
\end{tikzpicture}
\end{document}
如果我运行此代码,它会出现I don't know the path named 'data curve'
错误。
有办法让它工作吗?最后,图表将与彩色地图和文本合并为一个tikzpicture
,所以有些pstricks
不是一个可行的解决方案。前面的线性数据实例如下所示:
有没有我没看到的解决方案?我多次浏览手册,但什么也没找到。我的另一个想法是将额外的图表按比例放大到情节线和clip
网格线的上方和下方,但我不清楚如何实现这一点,如果它有效的话。