Re: [Pgfplots-features] Scatter (y)bar plots?

2013-06-10 Thread Christian Feuersaenger

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


Re: [Pgfplots-features] pgfplots and pgfplotstable numbers in XeLaTeX

2013-06-10 Thread Christian Feuersaenger
Hi Mike,

thanks for your interest in pgfplots! I am glad it proves to be useful.

Concerning your request to typeset ticks without math mode: you almost 
had it except that \pgfmathprintnumber beats you a bit. You are right; 
it really starts math mode implicitly.

There are two potential cures: the first is to write

\pgfmathprintnumber[assume math mode,verbatim]{\tick}%

and the second is to use \pgfmathprintnumberto instead of 
\pgfmathprintnumber, i.e. something like

   yticklabel={
 \pgfmathprintnumberto[verbatim]{\tick}\TEMP
 %
 \TEMP =
 %
 \romannumeral \TEMP%
 },

In the first solution, the 'assume math mode' key tells pgfmath that it 
should not ensure math mode on its own; it silently assumes that you 
know what you are doing.

The second solution does not typeout the numbers: it stores the result 
into the argument which comes after the number (in our case, it is 
\TEMP).  We can use this value in many ways; the simplest is to typeset 
it (by writing \TEMP). A more complicated way is to prefix it by 
\romannumeral (which is a bit strange, I admit it ;-)  ).

This should allow your use-case.

Kind regards

Christian

PS
I took the freedom to post a copy of this reply on the pgfplots mailing 
list in order to help others with similar problems. I hope you do not mind.


Am 10.06.2013 17:37, schrieb Michael Grant:
 Dear Sir,

 I have been a long time user of your excellent packages pgfplots and 
 pgfplotstable.  I am deeply grateful for the seamless integration of 
 numerical data to visual graphs your packages provide.

 I have recently had to use XeLaTeX to produce a document in a style 
 conformant to a corporate standard.  And notice that the ticks of a 
 pgfplot are formatted in math mode.

 I have solved the problem by 
 using: yticklabel={\pgfmathprintnumber[verbatim]{\tick}} and was 
 wondering if, on detection of an XeTex compiler the 
 \axisdefaultticklabel macro could be changed to

 \def\axisdefaultticklabel{\pgfmathprintnumber[verbatim]{\tick}}.

 Apropos, I see that even removing the math mode $'s still has 
 \pgfmathprintnumber producing text in math mode.

 Respectfully,

 Mike.
 This communication is intended for the addressee only. It is 
 confidential. If you have received this communication in error, please 
 notify us immediately and destroy the original message. You may not 
 copy or disseminate this communication without the permission of the 
 University. Only authorised signatories are competent to enter into 
 agreements on behalf of the University and recipients are thus advised 
 that the content of this message may not be legally binding on the 
 University and may contain the personal views and opinions of the 
 author, which are not necessarily the views and opinions of The 
 University of the Witwatersrand, Johannesburg. All agreements between 
 the University and outsiders are subject to South African Law unless 
 the University agrees in writing to the contrary.







--
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