2

I am using pgfplots to draw two images with polar coordinates. Even though I specify the same value that represents the 100% value (radius of a 100 for both red circles, they are the last plots in both images), pgfplots draws them with different dimensions that seem to be relative to the other values (other volumes illustrated with blue lines).

I have tried adding measurement units to the coordinates, but the results were the same. Another attempt was to set the y range, but that gave the same output.

I can always scale the images manually, but that will cause issues with the legends. The only case when I got identical red circles was when the values for the blue lines were less than 100.

I have included the code that I use to generate the images. The two tables can be found on this link:

https://www.dropbox.com/s/7u9g82zsw5eh55k/Tables.rar?dl=0

Is there a way to fix this issue and make the 100% value circles equal without scaling the images manually?

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsmath}

\usepackage{siunitx}
\usepackage{tikz} 
\usepackage{pgfplots}
\usepackage{pgfplotstable}


\usepackage{graphicx}

\pgfplotsset{compat=newest, legend cell align = left}
\usepgfplotslibrary{units}
\usepgfplotslibrary{polar}
\usetikzlibrary{hobby}

\newcommand{\addlegendentrySI}[3][]{%
  \begingroup\edef\x{\endgroup
    \noexpand\addlegendentry{
        \sisetup{zero-decimal-to-integer}
        $T_{m,\n}=\SI[#1]{#2}{#3}$}}\x
}

\begin{document}

\begin{tikzpicture}
\begin{polaraxis}[
        legend style={at={(0,.5)}, anchor=east, draw=none},
        transpose legend,
        legend columns=5,
        axis line style = {transparent},
        grid=none,
        ticks=none,
        clip=false,
        clip marker paths=true,
        cycle list name=mark list*]
    \pgfplotstableread{k_magma.txt}{\mytable} 
    \pgfplotstablegetrowsof{\mytable}
    \pgfmathsetmacro{\rows}{\pgfplotsretval-1}
        \foreach \i in {0,...,\rows}{%
        \pgfplotstablegetelem{\i}{Vp}\of{\mytable}
            \let\r\pgfplotsretval 
        \pgfplotstablegetelem{\i}{Angles}\of{\mytable}
            \let\a\pgfplotsretval
        \pgfplotstablegetelem{\i}{kmagma}\of{\mytable}
            \let\p\pgfplotsretval
        \pgfmathparse{int(\i+1)}
            \let\n\pgfmathresult
    \addplot+[color=blue, thick, solid, mark size=2] coordinates {(0,0)(\a,\r)};
        \addlegendentrySI{\p}{\watt(\meter\kelvin)^{-1}}
    }%
\addplot [hobby, dotted, no markers, color=blue, forget plot] table [x=Angles,y=Vp]{\mytable};
\addplot [blue, fill=blue, forget plot, domain=0:360, samples=360] {4};
\addplot [dotted, no markers, color=red, fill=red, fill opacity=0.1, samples=720, domain=0:360] {100};
\addlegendentry{$100\%V_b$}
\end{polaraxis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{polaraxis}[
        legend style={at={(0,.5)}, anchor=east, draw=none},
        transpose legend,
        legend columns=5,
        axis line style = {transparent},
        grid=none,
        ticks=none,
        clip=false,
        clip marker paths=true,
        cycle list name=mark list*]
    \pgfplotstableread{Cp_crust.txt}{\mytable} 
    \pgfplotstablegetrowsof{\mytable}
    \pgfmathsetmacro{\rows}{\pgfplotsretval-1}
        \foreach \i in {0,...,\rows}{%
        \pgfplotstablegetelem{\i}{Vp}\of{\mytable}
            \let\r\pgfplotsretval 
        \pgfplotstablegetelem{\i}{Angles}\of{\mytable}
            \let\a\pgfplotsretval
        \pgfplotstablegetelem{\i}{Cpcrust}\of{\mytable}
            \let\p\pgfplotsretval
        \pgfmathparse{int(\i+1)}
            \let\n\pgfmathresult
    \addplot+[color=blue, thick, solid, mark size=2] coordinates {(0,0)(\a,\r)};
\addlegendentrySI{\p}{\joule(\kilo\gram\kelvin)^{-1}}
    }%
\addplot [hobby, dotted, no markers, color=blue, forget plot] table [x=Angles,y=Vp]{\mytable};
\addplot [blue, fill=blue, forget plot, domain=0:360, samples=360] {4};
\addplot [dotted, no markers, color=red, fill=red, fill opacity=0.1, samples=720, domain=0:360] {100};
\addlegendentry{$100\%V_b$}
\end{polaraxis}
\end{tikzpicture}
\end{document}

The two images

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Martin Schröder May 15 '15 at 16:35
  • If you draw axis line and grid you'll see that both plots have equal size. And both maximum values are at same position but because their relation with 100% is different, red circles have different size. – Ignasi May 15 '15 at 17:04
  • Thank you for the tip. But is there a way to set the reference value to be the 100% circle and not the largest value present in the plot? – b.gegov May 15 '15 at 17:27

Your Answer

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

Browse other questions tagged or ask your own question.