[Matplotlib-users] Creating Colored Axis Labels using LaTeX in Interactive Mode

2016-07-11 Thread Joseph Fox-Rabinovitz
I originally posted to Stack Overflow at
http://stackoverflow.com/q/38274681/2988730.

I am trying to follow the answer at
http://stackoverflow.com/a/38008501/2988730 to an earlier question of
mine to create colored and styled legend-like entries. I have the
following code:

import matplotlib as mpl
mpl.use('ps')
from matplotlib import pyplot as plt

mpl.rc('text', usetex=True)
mpl.rc('text.latex', preamble='\\usepackage{color}\n\\usepackage{dashrule}')

plt.ion()
ax = plt.plot((0, 1), (1, 2))[0].axes
ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0,
0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}')
ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0,
0.0}{\rule[0.5ex]{3cm}{1pt}}')
plt.savefig('test.ps')

The result is as expected. The labels contain black text with a red
line on the Y label and a green line on the X label:
http://i.stack.imgur.com/JCiLI.png.

However, when I try the exact same set of commands without the
`mpl.use('ps')` line (using `'qt4agg'` backend on my system), the
figure neither saves corectly nor shows up correctly on screen:

import matplotlib as mpl
from matplotlib import pyplot as plt

mpl.rc('text', usetex=True)
mpl.rc('text.latex', preamble='\\usepackage{color}\n\\usepackage{dashrule}')

plt.ion()
ax = plt.plot((0, 1), (1, 2))[0].axes
ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0,
0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}')
ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0,
0.0}{\rule[0.5ex]{3cm}{1pt}}')

plt.savefig('test.png')
plt.show()

The result of `plt.savefig` (http://i.stack.imgur.com/h2LXn.png) and
`plt.show` (http://i.stack.imgur.com/0Ow7c.png) are basically the same
in this case. The lines after the text show up black.

How do I get the colors to show up in the labels with the default
interactive backend?

Regards,

-Joe

--
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How to set marker for a specific point in a scatter plot with colormap?

2016-07-11 Thread Chao YUE
Dear all matplotlib users,

I have a user case that, let's say I have three series data: x,y,z.
I would like to make a scatter plot using (x,y) as coordinates and z as the
color of scatter points, using cmap keyword of plt.scatter. However, I
would like to highlight some specific point by using a different marker (or
marker size) than other points.

​A minimum example is like below:
x,y,z = np.random.randn(3,10)
plt.scatter(x,y,c=z,cmap=matplotlib.cm.jet)
plt.colorbar()​

​If I want to use a different marker or marker size for (x[5],y[5],z[5]),
how could I do that?
The only way I can think of is to plot again for this point using
plt.scatter([x[5],y[5]) but define the color by manually finding the
colormap ​color corresponding to z[5]. However this is quite tedious. Is
there a better way?

​Thanks a lot for any help,

Regards,
Chao​

-- 
please visit:
http://www.globalcarbonatlas.org/
***
Chao YUE
postdoc at LSCE
CEA-Ormes des Merisiers, F-91191 GIF-SUR-YVETTE CEDEX
Tel: 33 1 69 08 41 87

--
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to set marker for a specific point in a scatter plot with colormap?

2016-07-11 Thread Chao YUE
OK, after posting I realize I can pass a vector to the 's' keyword in
plt.scatter to set the marker size, like s=[20,20,20,20,20,50,20,20,20,20].
How about using a different marker type? Thanks!

Regards,
Chao

On Mon, Jul 11, 2016 at 10:27 PM, Chao YUE  wrote:

> Dear all matplotlib users,
>
> I have a user case that, let's say I have three series data: x,y,z.
> I would like to make a scatter plot using (x,y) as coordinates and z as
> the color of scatter points, using cmap keyword of plt.scatter. However, I
> would like to highlight some specific point by using a different marker (or
> marker size) than other points.
>
> ​A minimum example is like below:
> x,y,z = np.random.randn(3,10)
> plt.scatter(x,y,c=z,cmap=matplotlib.cm.jet)
> plt.colorbar()​
>
> ​If I want to use a different marker or marker size for (x[5],y[5],z[5]),
> how could I do that?
> The only way I can think of is to plot again for this point using
> plt.scatter([x[5],y[5]) but define the color by manually finding the
> colormap ​color corresponding to z[5]. However this is quite tedious. Is
> there a better way?
>
> ​Thanks a lot for any help,
>
> Regards,
> Chao​
>
> --
> please visit:
> http://www.globalcarbonatlas.org/
>
> ***
> Chao YUE
> postdoc at LSCE
> CEA-Ormes des Merisiers, F-91191 GIF-SUR-YVETTE CEDEX
> Tel: 33 1 69 08 41 87
>
> 
>



-- 
please visit:
http://www.globalcarbonatlas.org/
***
Chao YUE
postdoc at LSCE
CEA-Ormes des Merisiers, F-91191 GIF-SUR-YVETTE CEDEX
Tel: 33 1 69 08 41 87

--
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to set marker for a specific point in a scatter plot with colormap?

2016-07-11 Thread Thomas Caswell
scatter does not (currently) support multiple markers in a single call.
You will have to do the group-by operation and call scatter is a loop.

If you define your cmap and norm outside of scatter, you can pass the same
instances into both calls to scatter to have mpl take care of that level of
mapping for you.

Tom

On Mon, Jul 11, 2016 at 3:32 PM Chao YUE  wrote:

> OK, after posting I realize I can pass a vector to the 's' keyword in
> plt.scatter to set the marker size, like s=[20,20,20,20,20,50,20,20,20,20].
> How about using a different marker type? Thanks!
>
> Regards,
> Chao
>
> On Mon, Jul 11, 2016 at 10:27 PM, Chao YUE  wrote:
>
>> Dear all matplotlib users,
>>
>> I have a user case that, let's say I have three series data: x,y,z.
>> I would like to make a scatter plot using (x,y) as coordinates and z as
>> the color of scatter points, using cmap keyword of plt.scatter. However, I
>> would like to highlight some specific point by using a different marker (or
>> marker size) than other points.
>>
>> ​A minimum example is like below:
>> x,y,z = np.random.randn(3,10)
>> plt.scatter(x,y,c=z,cmap=matplotlib.cm.jet)
>> plt.colorbar()​
>>
>> ​If I want to use a different marker or marker size for (x[5],y[5],z[5]),
>> how could I do that?
>> The only way I can think of is to plot again for this point using
>> plt.scatter([x[5],y[5]) but define the color by manually finding the
>> colormap ​color corresponding to z[5]. However this is quite tedious. Is
>> there a better way?
>>
>> ​Thanks a lot for any help,
>>
>> Regards,
>> Chao​
>>
>> --
>> please visit:
>> http://www.globalcarbonatlas.org/
>>
>> ***
>> Chao YUE
>> postdoc at LSCE
>> CEA-Ormes des Merisiers, F-91191 GIF-SUR-YVETTE CEDEX
>> Tel: 33 1 69 08 41 87
>>
>> 
>>
>
>
>
> --
> please visit:
> http://www.globalcarbonatlas.org/
>
> ***
> Chao YUE
> postdoc at LSCE
> CEA-Ormes des Merisiers, F-91191 GIF-SUR-YVETTE CEDEX
> Tel: 33 1 69 08 41 87
>
> 
>
> --
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users