Graphics, Figures & Tablespgfplots | Custom Axis Layout with Gaps in Data File

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Marco110981
Posts: 6
Joined: Thu Nov 20, 2008 3:35 am

pgfplots | Custom Axis Layout with Gaps in Data File

Post by Marco110981 »

Hello dear users.

I want to graphically display the results I obtained. I decided not to use MatLab and instead I will ask pgfplots to read my data from a file and draw the curves.

An example follows in attachment (refer to it when reading questions posted below).

There are some questions I could not answer (yet) and hope somebody out there may help me:
  1. Axis Layout: The standard output for these kind of graphics, is usually a box whose axes have the same size. I would like to stretch it, so that x-axis is (say) 4 or 5 times larger than y-axis. How can I do that?
  2. Marker: The time series I want to plot, does have some time gaps (i.e. some "no data available" during certain time spans). Of course it is necessary those gaps be well evident: no data means blank "hole" on the graph (MatLab language is NaN).
    Using default markers (or no markers at all) LaTeX does not produce any output in correspondence of the x-axis gap, but it does connect points bounding the gap segment. I had to ask LaTeX to use "Mark only" when drawing the plot so no line was drawn and gap segments remained blank.
    What I want to achieve is Draw a line (with no markers!) but still leave with spaces where data are "Not available/NaN/missing".
How can I do that?

Any input is sincerely appreciated
Thank you!
Kind regards from Lisbon

Marco
Attachments
Forum.pdf
(41.02 KiB) Downloaded 327 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

pgfplots | Custom Axis Layout with Gaps in Data File

Post by localghost »

Marco110981 wrote:Axis Layout: The standard output for these kind of graphics, is usually a box whose axes have the same size. I would like to stretch it, so that x-axis is (say) 4 or 5 times larger than y-axis. How can I do that?
You can specify a certain width and height in the option list for the axis environment. Refer to Section 3.6 (Scaling Plots, p. 12f) and Section 5.5 (Scaling options, p. 75ff) of the pgfplots manual.
Marco110981 wrote:Marker: The time series I want to plot, does have some time gaps (i.e. some "no data available" during certain time spans). Of course it is necessary those gaps be well evident: no data means blank "hole" on the graph (MatLab language is NaN).
Using default markers (or no markers at all) LaTex does not produce any output in correspondence of the x-axis gap, but it does connect points bounding the gap segment. I had to ask LaTeX to use "Mark only" when drawing the plot so no line was drawn and gap segments remained blank.
What I want to achieve is Draw a line (with no markers!) but still leave with spaces where data are "Not available/NaN/missing".
How can I do that?
Much more interesting than the resulting output is the source code. At the moment I'm not aware of the support for gaps in the data file. But perhaps there's only some more browsing of the manual necessary. And Chapter 8 could be of special interest for you.


Thorsten
Michael Schmid
Posts: 2
Joined: Wed Sep 05, 2012 4:53 pm

pgfplots | Custom Axis Layout with Gaps in Data File

Post by Michael Schmid »

Marco110981 wrote:What I want to achieve is [to] draw a line (with no markers) but still leave […] spaces where data are not available. How can I do that?
Since version 1.5, pgfplots provides that functionality. In the input file, leave an empty line for every gap. You might need to set the option compat=1.5 (or a newer version).

Source: {TeX} SX
feuersaenger
Posts: 34
Joined: Sun Oct 16, 2011 5:56 pm

pgfplots | Custom Axis Layout with Gaps in Data File

Post by feuersaenger »

pgfplots actually offers two ways to leave space:
  1. The first is to write NaN into the input stream (just as Matlab does) and tell pgfplots the option unbounded coords=jump. In this case, it will generate gaps explicitly (the default value unbounded coords=discard will silently discard such coordinates.
  2. The second option is to write empty lines into the input stream just as Michael said correctly.

Note:
Support for this unbounded coords feature has been added in version 1.3 (since January), so it was not present at the time the question was asked.
Post Reply