1

Since the values for the "FPGA" (Brown) chart is really small(0.0002, green doesnt show up), i wanted to use logarithmic scale instead. I tried using "ymode=log," but it makes the chart go wonky.

Additienter image description hereonally, I want to also add another right hand, y-axis to compare the throughput data, each bar graph having a value ranging from 0-2, probably a disconnected line plot.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}\begin{figure}[!h]
\centering
\begin{tikzpicture}
\begin{axis}[
    ybar,
    ymin=0,
    %enlargelimits=0.15,
                legend image code/.code={%
                    \draw[#1, draw=none] (0cm,-0.1cm) rectangle (0.6cm,0.1cm);
                },  
    legend style={at={(0.5,-0.10)},
      anchor=north,legend columns=-1},
    ylabel={Execution Time (ms)},
    symbolic x coords={RGB2GRAY,Gaussian,Box,Sobel},
    xtick=data,
    nodes near coords,
    nodes near coords align={vertical},
    ]
\addplot coordinates {(RGB2GRAY,33) (Gaussian,54)  (Box,127) (Sobel,246)  };%CPU
\addplot [fill=teal!]  coordinates {(RGB2GRAY,8.221) (Gaussian,13.3254)  (Box,14.958) (Sobel,29.935)  };%GPU
\addplot coordinates {(RGB2GRAY,20.234959834) (Gaussian,26.492609995)  (Box,27.353843832) (Sobel,45.59262995) };%FPGA
\legend{CPU,GPU,FPGA}
\end{axis}
\end{tikzpicture}
\caption{Algorithms Excluding Image Read/Write}
\label{imageexclude}
\end{figure}
\end{document}

1 Answer 1

0

This is not a full answer because the result is not pretty. Rather this is to tell you that ymode=log does work, at least in principle. The reason why the results look "wonky" is that by default log origin is set to 1, so some of the bars hang in the air. Changing this and putting repeating keys in a style (I actually do not know why ymode=log cannot be part of the style but this only one key) yields

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{figure}[!h]
\centering
\begin{tikzpicture}
\pgfplotsset{Freon axis/.style={ybar,
    ymin=0.00001,ymax=10000,%<- added ymax
    %enlargelimits=0.15,
                legend image code/.code={%
                    \draw[#1, draw=none] (0cm,-0.1cm) rectangle (0.6cm,0.1cm);
                },  
    legend style={at={(0.5,-0.10)},
      anchor=north,legend columns=-1},
    symbolic x coords={RGB2GRAY,Gaussian,Box, Sobel},
    xtick=data,
    nodes near coords,
    nodes near coords style={anchor=east,rotate=-90,inner xsep=1pt},
    log origin=infty
}}
\begin{axis}[Freon axis,ymode=log,ylabel={Execution Time (ms)}]
\addplot coordinates {(RGB2GRAY,54) (Gaussian,86)  (Box,154) (Sobel,268)  };%CPU
\addplot coordinates {(RGB2GRAY,170.71) (Gaussian, 172.065)  (Box,193.72) (Sobel,215.38)  };%GPU
\addplot coordinates {(RGB2GRAY,20.234959834) (Gaussian,26.492609995)  (Box,27.353843832) (Sobel,45.59262995) };%FPGA
\legend{CPU,GPU,FPGA}
\end{axis}


\begin{axis}[Freon axis,ymode=log,axis y line=right,ytick=\empty,
    ylabel={Throughput}]
\addplot [fill=green] coordinates {(RGB2GRAY,21) (Gaussian,32)  (Box,27) (Sobel,40)  };%CPU
\addplot [fill=green] coordinates {(RGB2GRAY,162.49) (Gaussian, 158.74)  (Box,178.76) (Sobel,169.79)  };%GPU
\addplot [fill=green] coordinates {(RGB2GRAY,0.0002) (Gaussian,0.0002)  (Box,0.0002) (Sobel,0.0002) };%FPGA
\end{axis}
\end{tikzpicture}
\caption{Algorithms Including Image Read/Write.}
\end{figure}
\end{document}

enter image description here

This is logarithmic but not pretty since now the brown bars grew but the red ones became too tiny. One could install a user transformation but I am not sure if this will then provide the viewer with the information you want to communicate.

9
  • I followed up on your question in the last post i made, to do with accounts, seems like its not really visually appealing in that way. i may aswell put it as a note at the bottom.
    – Freon
    Commented May 10, 2020 at 17:20
  • 1
    @Freon Thanks! I Wass assuming this is the case.
    – user194703
    Commented May 10, 2020 at 17:21
  • Also to through on the question, how would i go around adding a 2nd y-axis on the right?, I had some extra numbers "Throughput" (for each hardward/algo) i generated. I presume a line plot would work.
    – Freon
    Commented May 10, 2020 at 17:22
  • 1
    @Freon I didn't understand that part. What do you mean by another right hand, y-axis? Is this a separate plot or on top of the others?
    – user194703
    Commented May 10, 2020 at 17:24
  • 1
    @Freon I added an ylabel on the right but the other statements I do not really understand. Where do you get these numbers from? Note that you generate your plot with explicit coordinates rather than from a table, so it will be hard to get an automatic solution that computes new values from the existing ones.
    – user194703
    Commented May 10, 2020 at 17:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .