0

I can fit several boxplots onto the same page (actually into the same picture) but can't get more than 2 histograms vertically, and only 1 horizontally. How do you resize histograms and set the number you can fit per horizontal line? Maybe a pair should be in a single paragraph? Is there a standard style recommendation for this format?

Ideally I'd like to see 2 histograms side by side on a line and 6 lines per page. This would allow me to see 6 months of diastolic and systolic readings per page. I want to be able to identify trends in my daily blood pressure readings since my heart attack two years ago and ask my doctor about them.

The data files are a single column of numbers:

151
103
118
...
148

The tex for creating the histogram was simply lifted from the pgfplots manual, there are a few lines I don't understand but it works perfectly :

\begin{tikzpicture}
\begin{axis} [
title={September 2016},
ybar interval, % I don't think I need this line
xtick=, % I don't think I need this either
xticklabel= % I think this just gives a nicer font
{$ [ \pgfmathprintnumber\tick,%
\pgfmathprintnumber\nexttick)$}
]]

\addplot+[hist={data=x, bins=100}]
file {"c:/Documents and Settings/Dad/Desktop/bloodPressure/histsystolic_September2016.txt"};
\end{axis}
\end{tikzpicture}

Thanks very much for any help.

  • This should not be a problem. But to help us a bit it would be nice if you could edit your question and give as an MWE we can work with. If you don't want to share the real data or if they are too big, please replace them with some dummy data. – Stefan Pinnow Nov 4 '16 at 16:14
0

So you mean something like the following?

(I just plot random data here, because you didn't provide suitable data yourself.)

\documentclass[paper=A4,pagesize]{scrartcl}
\usepackage{pgfplots}
    \usetikzlibrary{
        % use `groupplots' library to easily put plots next to each other
        pgfplots.groupplots,
    }
    \pgfplotsset{
        % define a style which should be used for the plots
        my addplot style/.style={
            hist,
        },
    }
% just needed to know where the text area boundaries are
\usepackage{tikzpagenodes}
\begin{document}
    % this `tikzpicture' is just to know where the text area boundaries are
    \begin{tikzpicture}[remember picture,overlay]
        \draw [draw=red]
            (current page text area.north west)
                rectangle (current page text area.south east);
    \end{tikzpicture}
    \begin{tikzpicture}
        \begin{groupplot}[
            group style={
                group size=2 by 6,
                xticklabels at=edge bottom,
                yticklabels at=edge left,
                % adjust these two values depending on page and text area size
                % (together with `width' and `height')
                vertical sep=12.5mm,
                horizontal sep=5mm,
            },
            % adjust these two values depending on page and text area size
            % (together with `vertical sep' and `horizontal sep')
            width=0.425\textwidth,
            height=0.1\textheight,
            scale only axis,
            ybar interval, % I don't think I need this line
            xtick=, % I don't think I need this either
            xticklabel={%
                $[\pgfmathprintnumber\tick,\pgfmathprintnumber\nexttick)$%,
            },
        ]
        \nextgroupplot[title={January 2016 systolic}]
            \addplot+ [my addplot style] {rnd};
        \nextgroupplot[title={January 2016 diastolic}]
            \addplot+ [my addplot style] {rnd};

        \nextgroupplot[title={February 2016 systolic}]
            \addplot+ [my addplot style] {rnd};
        \nextgroupplot[title={February 2016 diastolic}]
            \addplot+ [my addplot style] {rnd};

        \nextgroupplot[title={March 2016 systolic}]
            \addplot+ [my addplot style] {rnd};
        \nextgroupplot[title={March 2016 diastolic}]
            \addplot+ [my addplot style] {rnd};

        \nextgroupplot[title={April 2016 systolic}]
            \addplot+ [my addplot style] {rnd};
        \nextgroupplot[title={April 2016 diastolic}]
            \addplot+ [my addplot style] {rnd};

        \nextgroupplot[title={May 2016 systolic}]
            \addplot+ [my addplot style] {rnd};
        \nextgroupplot[title={May 2016 diastolic}]
            \addplot+ [my addplot style] {rnd};

        \nextgroupplot[title={June 2016 systolic}]
            \addplot+ [my addplot style] {rnd};
        \nextgroupplot[title={June 2016 diastolic}]
            \addplot+ [my addplot style] {rnd};
        \end{groupplot}
    \end{tikzpicture}
\end{document}

image showing the result of above code

  • Besides accepting the answer you could also upvote it by clicking on the uparrow on the upper left of this answer. – Stefan Pinnow Dec 12 '16 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.