Re: [Pgfplots-features] Scatter (y)bar plots?
Hi Denis, there is a different solution which might work. I prepared it as low-level backend in order to implement a nice, understandable interface in pgfplots... however, it never made it that far and it is far from nice, understandable. It is a set of two hooks which is installed at the beginning and end of every bar. Combined with a bit of fine tuning, you get what you wanted... Here is the code: \documentclass{report} \usepackage{pgfplots} \pgfplotsset{compat=1.6} \pgfplotsset{ shaded bars/.style={ point meta=y, at begin bar={% \pgfplotsaxisvisphasetransformpointmeta \pgfplotscolormapdefinemappedcolor{\pgfplotspointmetatransformed}% \begin{scope}[left color=black,right color=mapped color]% \shade\pgfextra }, at end bar={% \endpgfextra; \end{scope}% }, }, } \begin{document} \thispagestyle{empty} \begin{tikzpicture} \begin{axis}[ybar] \addplot+[ shaded bars, colormap={test}{ color=(blue!10); color=(blue!20); color=(blue!30); color=(blue!40); color=(blue!50); color=(blue!60); color=(blue!70) }, ] plot coordinates { (1,1565) (2,1164) (3,740) (4,2273) (5,1688) (6,2942) }; \end{axis} \end{tikzpicture} \end{document} Attached is the result. You see that I did something slightly more complicated: I shaded the bars depending on the 'mapped color'. The 'shaded bars' style relies on the two (currently undocumented) keys 'at begin bar' and 'at end bar'. The two macros inside of it are mandatory; they take the raw point meta; map them into the min/max range and define the 'mapped color'. The rest is basically your example. I always wanted to improve the bar plot handler systematically - once I find time to do it; this kind of functionality will also receive attention. Kind regards Christian Am 06.06.2013 10:23, schrieb Denis Bitouzé: Hello, is there a way to get scatter (y)bar plots, I mean the bars filled with a colour depending on the y values? The following MCE doesn't give the expected result: %%% \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.8} \begin{document} \begin{tikzpicture} \begin{axis}[ybar] \addplot+[ colormap={test}{ color=(blue!10); color=(blue!20); color=(blue!30); color=(blue!40); color=(blue!50); color=(blue!60); color=(blue!70) }, scatter/use mapped color={draw=blue,fill=mapped color} ] plot coordinates { (1,1565) (2,1164) (3,740) (4,2273) (5,1688) (6,2942) }; \end{axis} \end{tikzpicture} \end{document} %%% Thanks. attachment: P.png\documentclass{report} \usepackage{pgfplots} \pgfplotsset{compat=1.6} \pgfplotsset{ shaded bars/.style={ point meta=y, at begin bar={% \pgfplotsaxisvisphasetransformpointmeta \pgfplotscolormapdefinemappedcolor{\pgfplotspointmetatransformed}% \begin{scope}[left color=black,right color=mapped color]% \shade\pgfextra }, at end bar={% \endpgfextra; \end{scope}% }, }, } \begin{document} \thispagestyle{empty} \begin{tikzpicture} \begin{axis}[ybar] \addplot+[ shaded bars, colormap={test}{ color=(blue!10); color=(blue!20); color=(blue!30); color=(blue!40); color=(blue!50); color=(blue!60); color=(blue!70) }, ] plot coordinates { (1,1565) (2,1164) (3,740) (4,2273) (5,1688) (6,2942) }; \end{axis} \end{tikzpicture} \end{document} -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev___ Pgfplots-features mailing list Pgfplots-features@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pgfplots-features
[Pgfplots-features] Scatter (y)bar plots?
Hello, is there a way to get scatter (y)bar plots, I mean the bars filled with a colour depending on the y values? The following MCE doesn't give the expected result: %%% \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.8} \begin{document} \begin{tikzpicture} \begin{axis}[ybar] \addplot+[ colormap={test}{ color=(blue!10); color=(blue!20); color=(blue!30); color=(blue!40); color=(blue!50); color=(blue!60); color=(blue!70) }, scatter/use mapped color={draw=blue,fill=mapped color} ] plot coordinates { (1,1565) (2,1164) (3,740) (4,2273) (5,1688) (6,2942) }; \end{axis} \end{tikzpicture} \end{document} %%% Thanks. -- Denis -- How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j ___ Pgfplots-features mailing list Pgfplots-features@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pgfplots-features
Re: [Pgfplots-features] Scatter (y)bar plots?
You could adapt the approach from http://tex.stackexchange.com/questions/116765/particular-bar-plot-with-pgfplots-bar-color-category/116773#116773 for this, which uses the `scatter/@pre marker code` to draw fake bars: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.8} \begin{document} \begin{tikzpicture} \begin{axis}[ymin=0] \addplot+[ scatter, only marks, colormap={test}{ color=(blue!10); color=(blue!20); color=(blue!30); color=(blue!40); color=(blue!50); color=(blue!60); color=(blue!70) }, scatter/use mapped color={draw=blue,fill=mapped color}, scatter/@pre marker code/.append code={ \pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed} \pgfmathsetmacro\negheight{-\pgfplotspointmeta} \fill [draw=black] (-1ex,0) rectangle ([xshift=1ex]axis direction cs:0,\negheight); \pgfplotsset{mark=none} }, ] plot coordinates { (1,1565) (2,1164) (3,740) (4,2273) (5,1688) (6,2942) }; \end{axis} \end{tikzpicture} \end{document} On 06/06/2013 04:23 AM, Denis Bitouzé wrote: Hello, is there a way to get scatter (y)bar plots, I mean the bars filled with a colour depending on the y values? The following MCE doesn't give the expected result: %%% \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.8} \begin{document} \begin{tikzpicture} \begin{axis}[ybar] \addplot+[ colormap={test}{ color=(blue!10); color=(blue!20); color=(blue!30); color=(blue!40); color=(blue!50); color=(blue!60); color=(blue!70) }, scatter/use mapped color={draw=blue,fill=mapped color} ] plot coordinates { (1,1565) (2,1164) (3,740) (4,2273) (5,1688) (6,2942) }; \end{axis} \end{tikzpicture} \end{document} %%% Thanks. -- How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j ___ Pgfplots-features mailing list Pgfplots-features@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pgfplots-features
Re: [Pgfplots-features] Scatter (y)bar plots?
Le jeudi 06/06/13 à 08h10, Juernjakob Dugge juernja...@gmail.com a écrit : You could adapt the approach from http://tex.stackexchange.com/questions/116765/particular-bar-plot-with-pgfplots-bar-color-category/116773#116773 for this, which uses the `scatter/@pre marker code` to draw fake bars: Wow! It is works like a charm and I would have been unable to find this solution by myself! Many thanks... Maybe such a feature could be implemented with a nice and understandable interface in pgfplots? :) Thanks again! -- Denis -- How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j ___ Pgfplots-features mailing list Pgfplots-features@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pgfplots-features