I'm using pst-plot package to make a figure that shows several plots with the same style. Like this:
I want to define my own pspicture with a command before the begin{document} tag, so that I can just enclose the plotting information inside a tag in the body, thus separating style from content.
This is the smallest minimal example code I was able to write that will show the first of the plots:
Code: Select all
\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage{graphicx,color}
\usepackage{pstricks,pst-plot,pstricks-add}
% The size of my figure:
\newcommand*{\ancho}{125.22mm}
\newcommand*{\alto} {270.26mm}
\special{papersize=\ancho,\alto}
% Free canvas: (basically zero everything)
\setlength{\hoffset}{-1in} \setlength{\voffset}{-1in}
\setlength{\marginparsep}{0cm} \setlength{\marginparwidth}{0cm}
\setlength{\oddsidemargin}{0cm} \setlength{\evensidemargin}{0cm} \setlength{\marginparpush}{0cm}
\setlength{\topmargin}{0cm} \setlength{\footskip}{0cm}
\setlength{\headsep}{0cm} \setlength{\headheight}{0cm}
\setlength{\textwidth} {\ancho} \setlength{\textheight} {\alto}
\setlength{\paperwidth}{\ancho} \setlength{\paperheight}{\alto}
\begin{document}
\pagestyle{empty} % No page numbering 'cos it's a figure
\centering
\psset{xunit=0.01748mm, yunit=1209.21mm,
plotstyle=bar, barwidth=2pt, fillstyle=solid, fillcolor=gray
}
\begin{pspicture}(-1350,-0.008)(5810,0.0665)
\psaxes[Dx=1000,Dy=0.02] (0,0)(5735,0.065)
\savedata{\mydata}[482,0.06]
\listplot{\mydata}
\end{pspicture}
\end{document}
Code: Select all
\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage{graphicx,color}
\usepackage{pstricks,pst-plot,pstricks-add}
% The size of my figure:
\newcommand*{\ancho}{125.22mm}
\newcommand*{\alto} {270.26mm}
\special{papersize=\ancho,\alto}
% Free canvas: (basically zero everything)
\setlength{\hoffset}{-1in} \setlength{\voffset}{-1in}
\setlength{\marginparsep}{0cm} \setlength{\marginparwidth}{0cm}
\setlength{\oddsidemargin}{0cm} \setlength{\evensidemargin}{0cm} \setlength{\marginparpush}{0cm}
\setlength{\topmargin}{0cm} \setlength{\footskip}{0cm}
\setlength{\headsep}{0cm} \setlength{\headheight}{0cm}
\setlength{\textwidth} {\ancho} \setlength{\textheight} {\alto}
\setlength{\paperwidth}{\ancho} \setlength{\paperheight}{\alto}
% ----------------- MY PSPICTURE ------------------------
\newcommand{\myfig}[1]{
\psset{xunit=0.01748mm, yunit=1209.21mm,
plotstyle=bar, barwidth=2pt, fillstyle=solid, fillcolor=gray
}
\begin{pspicture}(-1350,-0.008)(5810,0.0665)
\psaxes[Dx=1000,Dy=0.02] (0,0)(5735,0.065)
#1 % --------> MY PLOTTING STUFF
\end{pspicture}
}
\begin{document}
\pagestyle{empty} % No page numbering 'cos it's a figure
\centering
\myfig{ % MY CALL INSIDE THE DOCUMENT
\savedata{\mydata}[482,0.06]
\listplot{\mydata}
}
% ANOTHER PLOT WITH THE SAME STYLE
% \myfig{ ...STUFF... }
% ANOTHER PLOT WITH THE SAME STYLE
% \myfig{ ...STUFF... }
% ETC.
\end{document}
Code: Select all
latex myfig
dvips myfig.dvi -o myfig.ps
ps2pdf myfig.ps myfig.pdf
The first example, using pspicture inside the document, works fine.
The second example, calling an external pspicture, doesn't. I get a plot with nothing inside it, and an error in the last step when trying to convert to pdf. It starts with "Error: /undefined in 482,0.06", which is the point I am passing to savedata to make the plot.
Do you have any idea of why is it happening? Is there a better way to do this? Thanks in advanceError: /undefined in 482,0.06
Operand stack:
--nostringval--
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1910 1 3 %oparray_pop 1909 1 3 %oparray_pop 1893 1 3 %oparray_pop 1787 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:1161/1684(ro)(G)-- --dict:0/20(G)-- --dict:119/200(L)-- --dict:176/300(L)-- --dict:38/200(L)-- --dict:93/200(L)--
Current allocation mode is local
Last OS error: 2
Current file position is 137116
GPL Ghostscript 9.04: Unrecoverable error, exit code 1
