SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S



1
(12)
2
(14)
3
(13)
4
(6)
5
(6)
6
(21)
7
(29)
8
(30)
9
(13)
10
(4)
11
(4)
12
(4)
13
(15)
14
(22)
15
(23)
16
(23)
17
(9)
18
(23)
19
(12)
20
(10)
21
(26)
22
(5)
23
(32)
24
(5)
25
(7)
26
(4)
27
(3)
28
(19)
29
(20)



Showing results of 28

1 2 > >> (Page 1 of 2)
From: Yann T. <yan...@bu...> - 2012年02月07日 22:45:22
Along the lines of Mike's suggestion, I thought this could be done using
Latex.
I posted an answer on SO with an example of doing this, but it seems only
to work with postscript backend. Other backends override the color with the
mpl text color setting.
Is there a way to prevent this override? For example don't try to use 'PS'
backend, and look at hte figure interactively. It defaults to black.
http://stackoverflow.com/a/9185143/717357
-Yann
On Tue, Feb 7, 2012 at 4:46 PM, Paul Ivanov <piv...@gm...> wrote:
> Benjamin Root, on 2012年02月07日 13:46, wrote:
> > Also, how deep should this rabbit hole go? I could imagine one could
> want
> > this for title() and figtitle(). Maybe it would be best to implement
> this
> > at the Text() constructor level?
>
> For this reason, I would discourage even implementing such
> functionality in the core of matplotlib. This functionality doesn't strike
> me
> as something that ought to be available everywhere by default - if someone
> needs it, they can implement it as follows:
>
> -----
> import matplotlib.pyplot as plt
> from matplotlib import transforms
>
> def rainbow_text(x,y,ls,lc,**kw):
> """
> Take a list of strings ``ls`` and colors ``lc`` and place them next to
> each
> other, with text ls[i] being shown in color lc[i].
>
> This example shows how to do both vertical and horizontal text, and will
> pass all keyword arguments to plt.text, so you can set the font size,
> family, etc.
> """
> t = plt.gca().transData
> fig = plt.gcf()
> plt.show()
>
> #horizontal version
> for s,c in zip(ls,lc):
> text = plt.text(x,y," "+s+" ",color=c, transform=t, **kw)
> text.draw(fig.canvas.get_renderer())
> ex = text.get_window_extent()
> t = transforms.offset_copy(text._transform, x=ex.width,
> units='dots')
>
> #vertical version
> for s,c in zip(ls,lc):
> text = plt.text(x,y," "+s+" ",color=c, transform=t,
> rotation=90,va='bottom',ha='center',**kw)
> text.draw(fig.canvas.get_renderer())
> ex = text.get_window_extent()
> t = transforms.offset_copy(text._transform, y=ex.height,
> units='dots')
>
>
> plt.figure()
> rainbow_text(0.5,0.5,"all unicorns poop rainbows ! ! !".split(),
> ['red', 'orange', 'brown', 'green', 'blue', 'purple', 'black'],
> size=40)
>
> best,
> --
> Paul Ivanov
> 314 address only used for lists, off-list direct email at:
> http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Paul I. <piv...@gm...> - 2012年02月07日 21:47:02
Benjamin Root, on 2012年02月07日 13:46, wrote:
> Also, how deep should this rabbit hole go? I could imagine one could want
> this for title() and figtitle(). Maybe it would be best to implement this
> at the Text() constructor level?
For this reason, I would discourage even implementing such
functionality in the core of matplotlib. This functionality doesn't strike me
as something that ought to be available everywhere by default - if someone
needs it, they can implement it as follows:
-----
import matplotlib.pyplot as plt
from matplotlib import transforms
def rainbow_text(x,y,ls,lc,**kw):
 """
 Take a list of strings ``ls`` and colors ``lc`` and place them next to each
 other, with text ls[i] being shown in color lc[i].
 This example shows how to do both vertical and horizontal text, and will
 pass all keyword arguments to plt.text, so you can set the font size,
 family, etc.
 """
 t = plt.gca().transData
 fig = plt.gcf()
 plt.show()
 #horizontal version
 for s,c in zip(ls,lc):
 text = plt.text(x,y," "+s+" ",color=c, transform=t, **kw)
 text.draw(fig.canvas.get_renderer())
 ex = text.get_window_extent()
 t = transforms.offset_copy(text._transform, x=ex.width, units='dots')
 #vertical version
 for s,c in zip(ls,lc):
 text = plt.text(x,y," "+s+" ",color=c, transform=t,
 rotation=90,va='bottom',ha='center',**kw)
 text.draw(fig.canvas.get_renderer())
 ex = text.get_window_extent()
 t = transforms.offset_copy(text._transform, y=ex.height, units='dots')
plt.figure()
rainbow_text(0.5,0.5,"all unicorns poop rainbows ! ! !".split(), 
 ['red', 'orange', 'brown', 'green', 'blue', 'purple', 'black'],
 size=40)
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: Jason G. <jas...@cr...> - 2012年02月07日 21:21:52
On 2/7/12 2:47 PM, Michael Droettboom wrote:
> since this would never be full-fledged HTML anyway [1].
Famous last words, right?
I'm curious: for the SVG backend, or a possible html5 canvas backend, 
can we already include html? I don't know, but I'm curious.
Jason
From: Michael D. <md...@st...> - 2012年02月07日 20:49:11
In the past, I've thought having some sort of "HTML-lite" subset would 
be the most powerful here. So one could do:
 title("This is <b>bold</b>")
Strictly speaking, for colors, one would do:
 title("This is <font color='red'>red</font>")
but that's awfully verbose. I wouldn't have a problem fudging the spec 
and supporting:
 title("This is <red>red</red>")
since this would never be full-fledged HTML anyway [1].
The advantage of this approach over any of the list-based ones is that 
different properties can be nested, and I think most people understand 
the basics of HTML/XML tags.
And I agree with Benjamin, that this should be at the Text() constructor 
level so it works everywhere. I envision it being a sort of peer text 
parser just as the mathtext parser is now -- in fact a lot of the 
mathtext machinery would be reused.
[1] Of course, I've also considered using something like PythonWebKit to 
render text for us -- the advantage being we'd also get proper bidi and 
other internationalization features. But (a) WebKit is another honking 
dependency and (b) I'm not sure the Python bindings are ready for prime 
time.
Mike
On 02/07/2012 02:46 PM, Benjamin Root wrote:
>
>
> On Tue, Feb 7, 2012 at 1:15 PM, Gökhan Sever <gok...@gm... 
> <mailto:gok...@gm...>> wrote:
>
> I was basing my whitespace split idea on single string assumption
> --eg. no list passing.
>
> I do not have a strong preference on the final argument passing,
> as long as it works instead of manually placing the texts on
> figure or axis :)
>
>
>
> On Tue, Feb 7, 2012 at 11:52 AM, Ryan May <rm...@gm...
> <mailto:rm...@gm...>> wrote:
>
> On Tue, Feb 7, 2012 at 12:49 PM, Gökhan Sever
> <gok...@gm... <mailto:gok...@gm...>> wrote:
> > This works as well, as long as it functions :)
> >
> > My idea requires little less typing. But forgot previously,
> text string
> > should be whitespace split.
>
> Right, but we shouldn't guess. If we automatically split on
> whitespace, this becomes harder:
>
> plt.ylabel(["The sun is", "yellow"], ['k', 'y'])
>
> Ryan
>
>
> I think the python mantra of "explicit over implicit" should be 
> followed here. I don't think we currently allow list of strings, so 
> there is no risk of breaking existing scripts, I think. We probably 
> should confirm that just in case.
>
> Also, how deep should this rabbit hole go? I could imagine one could 
> want this for title() and figtitle(). Maybe it would be best to 
> implement this at the Text() constructor level?
>
> Ben Root
>
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Gökhan S. <gok...@gm...> - 2012年02月07日 20:41:47
On Tue, Feb 7, 2012 at 12:46 PM, Benjamin Root <ben...@ou...> wrote:
>
>
> On Tue, Feb 7, 2012 at 1:15 PM, Gökhan Sever <gok...@gm...>wrote:
>
>> I was basing my whitespace split idea on single string assumption --eg.
>> no list passing.
>>
>> I do not have a strong preference on the final argument passing, as long
>> as it works instead of manually placing the texts on figure or axis :)
>>
>>
>>
>> On Tue, Feb 7, 2012 at 11:52 AM, Ryan May <rm...@gm...> wrote:
>>
>>> On Tue, Feb 7, 2012 at 12:49 PM, Gökhan Sever <gok...@gm...>
>>> wrote:
>>> > This works as well, as long as it functions :)
>>> >
>>> > My idea requires little less typing. But forgot previously, text string
>>> > should be whitespace split.
>>>
>>> Right, but we shouldn't guess. If we automatically split on
>>> whitespace, this becomes harder:
>>>
>>> plt.ylabel(["The sun is", "yellow"], ['k', 'y'])
>>>
>>> Ryan
>>>
>>>
> I think the python mantra of "explicit over implicit" should be followed
> here. I don't think we currently allow list of strings, so there is no
> risk of breaking existing scripts, I think. We probably should confirm
> that just in case.
>
>
Fair enough.
> Also, how deep should this rabbit hole go? I could imagine one could want
> this for title() and figtitle(). Maybe it would be best to implement this
> at the Text() constructor level?
>
ylabel text coloring works for me for the time being. However, a general
implementation would possibly fulfill other incoming requests.
>
> Ben Root
>
>
-- 
Gökhan
From: Patrick M. <pat...@gm...> - 2012年02月07日 19:59:08
Congratulations, Ben! That's an awesome story!
I am by no means at the level of competence that Ben (or Ryan May,
another matplotlib contributor and meteorology PhD student at OU) but
have been able to turn what I've learned from lurking on the MPL
listserv (as well as the Numpy/Scipy listservs) into an improved lot
in life. By no means is it a permanent job, but based on what I've
learned from everyone here, I was able to land what amounts to a
Post-Doc position with the National Severe Storms Laboratory, while I
work toward finishing my PhD. It's so much so that I spend more of my
time actually helping solve other's MPL/Numpy/Scipy problems than I do
working on my own stuff! I'll admit there are times where I think to
myself I should be more selfish and focus on finishing my degree, but
I believe that I owe it to the community to give back, even if it is
off-list. My knowledge is a product of your knowledge and thus I
believe I'm obligated to share it with those around me who lack it,
but desperately need it.
I have to admit, when I first came to the world of Python (from Java
and C), I was amazed at the tools readily available --- the
matplotlib, numpy, and scipys of the community. Specific to MPL, I
thought it was the greatest thing ever. I did all of my plotting with
it. However, as I got into more advanced Python programming and
needed more complex examples, I became frustrated and discouraged that
I couldn't do exactly what I wanted. So much so, that I temporarily
switched to R and the use of the ggplot2 package. However, as I
continued to advance I learned the beauty of matplotlib and realized
just how powerful it actually was. I began to see how to do all the
things I couldn't do before. It's powerful enough that I'm forcing
those around me to switch to Python and MPL, not because I'm telling
them they have to, but because they see what I'm doing with it and
realize that in order to keep up, they need to make the switch.
As I continue to mature as a Python person, I want to give back
explicitly to the community that's given so much to me. The problem
is, I don't know how. I'm intimidated by the awesomeness of what I see
being done around me that I don't even know where to begin. How does
one even begin to learn how to understand the deep intricacies of MPL,
Numpy, and Scipy so that I'd begin to develop a comfort level that
would allow me to begin to actively contribute? I know pretty much
everyone on these listservs, including myself, is busy. (I'm in the
midst of a 30-day PhD General Exam, and probably shouldn't even be
reading the listservs and/or typing this email! *wink*) But if there
are those out there that are willing to take a little time and invest
in me, and I'm sure there are others like me, I'd gladly become an
active contributor instead of a lurker.
Anyways, I know this email is a tad on the long side, and a little off
the original topic, so if you're still reading, thanks! This is
something that's been weighing on me for a few months now, and I
thought Ben's exultation of the benefits of the community might be a
good time to open up.
Cheers,
Patrick
---
Patrick Marsh
Ph.D. Student / Liaison to the HWT
School of Meteorology / University of Oklahoma
Cooperative Institute for Mesoscale Meteorological Studies
National Severe Storms Laboratory
http://www.patricktmarsh.com
On Tue, Feb 7, 2012 at 11:19 AM, Fernando Perez <fpe...@gm...> wrote:
> On Tue, Feb 7, 2012 at 9:02 AM, Ethan Gutmann <eth...@gm...> wrote:
>>
>> Also, congrats Ben, both on finishing the PhD and on the job. If you ever find yourself in Boulder, CO (I'm at NCAR), let me know and I'll buy you a drink.
>
> Indeed, congrats to Ben! And I'm very glad to see your many
> contributions to the project finding acknowledgment and long-term
> benefits for you.
>
> BTW Ethan, it's been a few years since the last time that John Hunter
> and I lectured at NCAR (Dec. 2007), but in early April Min
> Ragan-Kelley and I will be teaching at a workshop at CU, focusing on
> data analysis with the 'scipy stack' and ipython's parallel machinery.
> This will be in the context of a genomics workshop on campus, but if
> you are interested we might be able to meet up with some of the python
> crowd at NCAR...
>
> Just let me know if you are interested; best to write to
> fer...@be..., as I sometimes stop monitoring mailing
> lists if I get swamped.
>
> Cheers,
>
> f
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Benjamin R. <ben...@ou...> - 2012年02月07日 19:47:09
On Tue, Feb 7, 2012 at 1:15 PM, Gökhan Sever <gok...@gm...> wrote:
> I was basing my whitespace split idea on single string assumption --eg. no
> list passing.
>
> I do not have a strong preference on the final argument passing, as long
> as it works instead of manually placing the texts on figure or axis :)
>
>
>
> On Tue, Feb 7, 2012 at 11:52 AM, Ryan May <rm...@gm...> wrote:
>
>> On Tue, Feb 7, 2012 at 12:49 PM, Gökhan Sever <gok...@gm...>
>> wrote:
>> > This works as well, as long as it functions :)
>> >
>> > My idea requires little less typing. But forgot previously, text string
>> > should be whitespace split.
>>
>> Right, but we shouldn't guess. If we automatically split on
>> whitespace, this becomes harder:
>>
>> plt.ylabel(["The sun is", "yellow"], ['k', 'y'])
>>
>> Ryan
>>
>>
I think the python mantra of "explicit over implicit" should be followed
here. I don't think we currently allow list of strings, so there is no
risk of breaking existing scripts, I think. We probably should confirm
that just in case.
Also, how deep should this rabbit hole go? I could imagine one could want
this for title() and figtitle(). Maybe it would be best to implement this
at the Text() constructor level?
Ben Root
On Tue, Feb 7, 2012 at 1:01 PM, Martin Mokrejs
<mmo...@fo...>wrote:
> Hi,
> I would like to create a bar chart like the attached example but with the
> addition
> that each bar would have a different color. I tried to learn this from the
> examples
> on matplotlib web but still do not see a close example for that. ;-)
> many thanks,
> Martin
>
>
Here's an example that does what you want (I think). There may be a better
way of setting the colors of the bars, but I don't use bar plots very often.
Hope that helps,
-Tony
import numpy as np
import matplotlib.pyplot as plt
colorcycle = ['red',
 'steelblue',
 'gold',
 'darkorchid',
 'yellowgreen',
 'darkorange',
 'silver',
 'darkturquoise',
 'hotpink',
 'mediumblue']
yy = np.random.uniform(5, 200, size=10).astype(int)
xx = range(len(yy))
width = 0.5
bars = plt.bar(xx, yy, width=width)
# add bar labels
for x, y in zip(xx, yy):
 plt.text(x + 0.5*width, y, str(y), ha='center', va='bottom')
# change color of bars
for b, c in zip(bars, colorcycle):
 b.set_color(c)
plt.show()
From: Gökhan S. <gok...@gm...> - 2012年02月07日 19:16:03
I was basing my whitespace split idea on single string assumption --eg. no
list passing.
I do not have a strong preference on the final argument passing, as long as
it works instead of manually placing the texts on figure or axis :)
On Tue, Feb 7, 2012 at 11:52 AM, Ryan May <rm...@gm...> wrote:
> On Tue, Feb 7, 2012 at 12:49 PM, Gökhan Sever <gok...@gm...>
> wrote:
> > This works as well, as long as it functions :)
> >
> > My idea requires little less typing. But forgot previously, text string
> > should be whitespace split.
>
> Right, but we shouldn't guess. If we automatically split on
> whitespace, this becomes harder:
>
> plt.ylabel(["The sun is", "yellow"], ['k', 'y'])
>
> Ryan
>
> --
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
>
-- 
Gökhan
From: Ryan M. <rm...@gm...> - 2012年02月07日 18:53:01
On Tue, Feb 7, 2012 at 12:49 PM, Gökhan Sever <gok...@gm...> wrote:
> This works as well, as long as it functions :)
>
> My idea requires little less typing. But forgot previously, text string
> should be whitespace split.
Right, but we shouldn't guess. If we automatically split on
whitespace, this becomes harder:
plt.ylabel(["The sun is", "yellow"], ['k', 'y'])
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Gökhan S. <gok...@gm...> - 2012年02月07日 18:49:13
This works as well, as long as it functions :)
My idea requires little less typing. But forgot previously, text string
should be whitespace split.
On Tue, Feb 7, 2012 at 11:43 AM, Benjamin Root <ben...@ou...> wrote:
>
>
> On Tue, Feb 7, 2012 at 12:38 PM, Gökhan Sever <gok...@gm...>wrote:
>
>> Posted at https://github.com/matplotlib/matplotlib/issues/697
>>
>> I think a syntax like:
>>
>> plt.ylabel("Sun is shining.", color='rgb')
>>
>> would be a good start. (Assuming len of string == len of colors)
>>
>>
> Don't know if I like that. It becomes even more difficult to convert the
> color spec into rgb. How about this?
>
> plt.ylabel(['Sun", "is", "shining"], color=['r', 'g', 'b'])
>
> By having the input label be an array, that would force ylabel to
> recognize that the color sequence should also be treated similarly.
>
> Ben Root
>
>
-- 
Gökhan
From: Benjamin R. <ben...@ou...> - 2012年02月07日 18:43:40
On Tue, Feb 7, 2012 at 12:38 PM, Gökhan Sever <gok...@gm...> wrote:
> Posted at https://github.com/matplotlib/matplotlib/issues/697
>
> I think a syntax like:
>
> plt.ylabel("Sun is shining.", color='rgb')
>
> would be a good start. (Assuming len of string == len of colors)
>
>
Don't know if I like that. It becomes even more difficult to convert the
color spec into rgb. How about this?
plt.ylabel(['Sun", "is", "shining"], color=['r', 'g', 'b'])
By having the input label be an array, that would force ylabel to recognize
that the color sequence should also be treated similarly.
Ben Root
From: Gökhan S. <gok...@gm...> - 2012年02月07日 18:38:53
Posted at https://github.com/matplotlib/matplotlib/issues/697
I think a syntax like:
plt.ylabel("Sun is shining.", color='rgb')
would be a good start. (Assuming len of string == len of colors)
On Tue, Feb 7, 2012 at 11:18 AM, Michael Droettboom <md...@st...> wrote:
> Nope. But it's something I've wanted to add for a while. Can you file
> an Issue in the github tracker?
>
> Mike
>
>
> On 02/07/2012 11:40 AM, Gökhan Sever wrote:
>
> Is there a way in matplotlib to partially specify the color of a string?
>
> Example:
>
> plt.ylabel("Today is cloudy.")
> How can I show "today" as red, "is" as green and "cloudy." as blue?
>
> Thanks.
>
> PS: Asked also on
> http://stackoverflow.com/questions/9169052/partial-coloring-of-text-in-matplotlib
>
> --
> Gökhan
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!http://p.sf.net/sfu/learndevnow-d2d
>
>
>
> _______________________________________________
> Matplotlib-users mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
-- 
Gökhan
From: Benjamin R. <ben...@ou...> - 2012年02月07日 18:33:57
On Tue, Feb 7, 2012 at 12:30 PM, Mark Janikas <mja...@es...> wrote:
> I downloaded DejaVu Sans and pointed to that ttf file, and no love L...
> Again, the default font seems to work for English, French, German, Spanish,
> Italian other Euros etal... but Chinese and Arabic either come out blank
> (default font, DejaVu Sans) or choke on the glyphs (MS Unicode). ****
>
> ** **
>
> MJ****
>
> **
>
Just a quick sanity check, does everything work properly if you render to
the screen or to a PNG file? What about EPS?
Ben Root
From: Mark J. <mja...@es...> - 2012年02月07日 18:30:29
I downloaded DejaVu Sans and pointed to that ttf file, and no love :(... Again, the default font seems to work for English, French, German, Spanish, Italian other Euros etal... but Chinese and Arabic either come out blank (default font, DejaVu Sans) or choke on the glyphs (MS Unicode).
MJ
From: Michael Droettboom [mailto:md...@st...]
Sent: Tuesday, February 07, 2012 6:56 AM
To: mat...@li...
Subject: Re: [Matplotlib-users] rendering unicode using the PDF backend
It looks like perhaps we'll need to "synthesize" glyph names if they aren't provided in the font (though it's not clear to me why they are not). This will be difficult to test for, as that's a proprietary font. Have you tried using another Unicode font, such as DejaVu Sans?
Mike
On 02/06/2012 06:53 PM, Mark Janikas wrote:
Hi All,
I am having trouble rendering my Unicode strings in matplotlib using the PDF backend. When I use certain fonts (like the Win 7 default), I get no complaints but the characters are not rendered.... When I use a font like Arial Unicode MS, that I know contains all the chars, then I get the error message below. I did in fact, find a tty file that would work with Chinese ("Microsoft YaHei"), but I would like to avoid trying to map font files to languages. Any info on this subject would be greatly appreciated. Here is a snippet that reproduces the error below... if you remove the fontproperties option to the PYLAB.xlabel() call then the error is avoided but the result is not rendered. Thanks so much!
MJ
import matplotlib.pyplot as PLT
import pylab as PYLAB
from matplotlib.backends.backend_pdf import PdfPages as PDF
import matplotlib.font_manager as fm
fontFile = r'C:\Windows\Fonts\ARIALUNI.TTF'
fp1 = fm.FontProperties(fname=fontFile)
reportFile = r'C:\Temp\TestUnicode.pdf'
pdfOutput = PDF(reportFile)
vals = range(100)
PLT.plot(vals, vals, color = "r", linestyle = "-")
mess = u'\u6B63\u5728\u8BFB\u53D6\u6570\u636E...'
PYLAB.xlabel(mess, fontproperties = fp1)
PLT.savefig(pdfOutput, format='pdf')
PLT.close()
pdfOutput.close()
Traceback (most recent call last):
 File "C:\Data\CRs10円.1\MemLeak\matplotlib\Scripts\matplotlib_unicode.py", line 27, in <module>
 PLT.savefig(pdfOutput, format='pdf')
 File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 472, in savefig
 return fig.savefig(*args, **kwargs)
 File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 1173, in savefig
 self.canvas.print_figure(*args, **kwargs)
 File "C:\Python27\lib\site-packages\matplotlib\backend_bases.py", line 2027, in print_figure
 **kwargs)
 File "C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", line 2181, in print_pdf
 self.figure.draw(renderer)
 File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
 draw(artist, renderer, *args, **kwargs)
 File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 886, in draw
 func(*args)
 File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
 draw(artist, renderer, *args, **kwargs)
 File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1983, in draw
 a.draw(renderer)
 File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
 draw(artist, renderer, *args, **kwargs)
 File "C:\Python27\lib\site-packages\matplotlib\axis.py", line 1054, in draw
 self.label.draw(renderer)
 File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
 draw(artist, renderer, *args, **kwargs)
 File "C:\Python27\lib\site-packages\matplotlib\text.py", line 587, in draw
 ismath=ismath)
 File "C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", line 1784, in draw_text
 return draw_text_woven(chunks)
 File "C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", line 1754, in draw_text_woven
 glyph_name = font.get_glyph_name(gind)
RuntimeError: Face has no glyph names
PS. I cannot use a different backend.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Matplotlib-users mailing list
Mat...@li...<mailto:Mat...@li...>
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Michael D. <md...@st...> - 2012年02月07日 18:18:59
Nope. But it's something I've wanted to add for a while. Can you file 
an Issue in the github tracker?
Mike
On 02/07/2012 11:40 AM, Gökhan Sever wrote:
> Is there a way in matplotlib to partially specify the color of a string?
>
> Example:
>
> plt.ylabel("Today is cloudy.")
> How can I show "today" as red, "is" as green and "cloudy." as blue?
>
> Thanks.
>
> PS: Asked also on 
> http://stackoverflow.com/questions/9169052/partial-coloring-of-text-in-matplotlib
>
> -- 
> Gökhan
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Hi,
 I would like to create a bar chart like the attached example but with the addition
that each bar would have a different color. I tried to learn this from the examples
on matplotlib web but still do not see a close example for that. ;-)
many thanks,
Martin
From: Fernando P. <fpe...@gm...> - 2012年02月07日 17:20:05
On Tue, Feb 7, 2012 at 9:02 AM, Ethan Gutmann <eth...@gm...> wrote:
>
> Also, congrats Ben, both on finishing the PhD and on the job. If you ever find yourself in Boulder, CO (I'm at NCAR), let me know and I'll buy you a drink.
Indeed, congrats to Ben! And I'm very glad to see your many
contributions to the project finding acknowledgment and long-term
benefits for you.
BTW Ethan, it's been a few years since the last time that John Hunter
and I lectured at NCAR (Dec. 2007), but in early April Min
Ragan-Kelley and I will be teaching at a workshop at CU, focusing on
data analysis with the 'scipy stack' and ipython's parallel machinery.
 This will be in the context of a genomics workshop on campus, but if
you are interested we might be able to meet up with some of the python
crowd at NCAR...
Just let me know if you are interested; best to write to
fer...@be..., as I sometimes stop monitoring mailing
lists if I get swamped.
Cheers,
f
From: Paul I. <piv...@gm...> - 2012年02月07日 17:12:28
C M, on 2012年02月06日 09:33, wrote:
> On Mon, Feb 6, 2012 at 9:23 AM, David Craig <dcd...@gm...> wrote:
> 
> > Hi, I have a plot and the xaxis shows number of seconds after a start
> > point. I would like to convert them to days anyone know how to do this.
> > I have looked at the documentation but cant find what I need.
> 
> Couldn't you divide your data points by the conversion (86400) before
> plotting? E.g., 432,000 seconds then becomes 5 days.
Another way to do this is to change the Formatter which generates
what the labels of each tick out to be to do this computation.
Take a look at this example:
http://matplotlib.sourceforge.net/examples/api/date_index_formatter.html
Just define something like:
def your_function(x,pos=None):
 return "%d days" % (x/86400)
ax.xaxis.set_major_formatter(ticker.FuncFormatter(your_function))
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: Ethan G. <eth...@gm...> - 2012年02月07日 17:02:51
On Feb 7, 2012, at 1:42 AM, Friedrich Romstedt wrote:
> I'd like to thank John and Ben for this inspiring posts, which showed
> them from a side I've never seen so far. Show your hands if you're
> thinking the same. I hope I didn't bore you all :-)
Well said Friedrich, though I'm a relative newcomer to python/matplotlib, I've been on the peripheral of a lot of open source, and I've enjoyed this thread. 
Also, congrats Ben, both on finishing the PhD and on the job. If you ever find yourself in Boulder, CO (I'm at NCAR), let me know and I'll buy you a drink. 
ethan
From: Paul I. <piv...@gm...> - 2012年02月07日 16:55:29
Hi Phil,
phils, on 2012年02月04日 07:41, wrote:
> Newbie to using matplotlib
welcome to the party :)
 
> Is it possible to use wx and have a window with say 2 buttons on where when
> clicking on either button a different graph will appear using a different
> data set. Any examples?
Yes, it's possible. Here's a modified version of
examples/event_handling/keypress_demo.py which toggles between
two different axes when you press the 'w' key on your keyboard:
one has green points connected by dashed lines, the other with
multi-colored multi-sized scatter data.
--------
import numpy as np
import matplotlib.pyplot as plt
plt.close('all')
def press(event):
 print('press', event.key)
 if event.key=='w':
 visible = ax.get_visible()
 ax.set_visible(not visible)
 ax2.set_visible(visible)
 fig.canvas.draw()
fig = plt.figure()
ax = fig.add_axes([.1,.1,.8,.8], label='one')
ax2 = fig.add_axes([.1,.1,.8,.8], label='two')
ax2.set_visible(False)
fig.canvas.mpl_connect('key_press_event', press)
ax.plot(np.random.rand(12), np.random.rand(12), 'go--')
ax2.scatter(100*np.random.rand(12), 100*np.random.rand(12),
 c=np.random.rand(12), s=np.random.rand(12)*100)
plt.show()
--------
I don't want to take away all of your fun, so have a look at
adding (mouse clickable) buttons to this using either
examples/widgets/buttons.py or examples/widgets/radio_buttons.py
- depending on your preference.
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
On 02/07/2012 10:48 AM, Benjamin Root wrote:
>
>
> On Tue, Feb 7, 2012 at 8:33 AM, Fabien Lafont <laf...@gm... 
> <mailto:laf...@gm...>> wrote:
>
> Is it possible to set the extension .pdf as defaut when I save an
> image using the matplotlib bar. My coworkers are always saving the
> image in png and it's really ugly!
>
> Thx,
>
> Fab
>
>
> Interesting request. Looking through the backends, it appears that 
> only the Cairo backend currently supports a configurable rcParam for 
> the default filetype ('cairo.format'). All backends implement a 
> "get_default_filetype()" method for their canvases, but most of them 
> have that default hard-coded as "png". This really only makes sense 
> for backends like agg, pdf, ps and such.
>
> Devs - Maybe we should consider fixing this for the non-fileformat 
> specific backends? Do we want an rcParam for each backend? Or a 
> single rcParam for default filetypes and deprecate 'cairo.format'?
I would definitely lean toward the latter -- unify it under a single 
rcParam.
Mike
From: Gökhan S. <gok...@gm...> - 2012年02月07日 16:40:52
Is there a way in matplotlib to partially specify the color of a string?
Example:
plt.ylabel("Today is cloudy.")
How can I show "today" as red, "is" as green and "cloudy." as blue?
Thanks.
PS: Asked also on
http://stackoverflow.com/questions/9169052/partial-coloring-of-text-in-matplotlib
-- 
Gökhan
On Tue, Feb 7, 2012 at 8:33 AM, Fabien Lafont <laf...@gm...>wrote:
> Is it possible to set the extension .pdf as defaut when I save an
> image using the matplotlib bar. My coworkers are always saving the
> image in png and it's really ugly!
>
> Thx,
>
> Fab
>
>
Interesting request. Looking through the backends, it appears that only
the Cairo backend currently supports a configurable rcParam for the default
filetype ('cairo.format'). All backends implement a
"get_default_filetype()" method for their canvases, but most of them have
that default hard-coded as "png". This really only makes sense for
backends like agg, pdf, ps and such.
Devs - Maybe we should consider fixing this for the non-fileformat specific
backends? Do we want an rcParam for each backend? Or a single rcParam for
default filetypes and deprecate 'cairo.format'?
Cheers!
Ben Root
From: Michael D. <md...@st...> - 2012年02月07日 14:55:56
It looks like perhaps we'll need to "synthesize" glyph names if they 
aren't provided in the font (though it's not clear to me why they are 
not). This will be difficult to test for, as that's a proprietary 
font. Have you tried using another Unicode font, such as DejaVu Sans?
Mike
On 02/06/2012 06:53 PM, Mark Janikas wrote:
>
> Hi All,
>
> I am having trouble rendering my Unicode strings in matplotlib using 
> the PDF backend. When I use certain fonts (like the Win 7 default), 
> I get no complaints but the characters are not rendered.... When I use 
> a font like Arial Unicode MS, that I know contains all the chars, then 
> I get the error message below. I did in fact, find a tty file that 
> would work with Chinese ("Microsoft YaHei"), but I would like to avoid 
> trying to map font files to languages. Any info on this subject would 
> be greatly appreciated. Here is a snippet that reproduces the error 
> below... if you remove the fontproperties option to the PYLAB.xlabel() 
> call then the error is avoided but the result is not rendered. Thanks 
> so much!
>
> MJ
>
> import matplotlib.pyplot as PLT
>
> import pylab as PYLAB
>
> from matplotlib.backends.backend_pdf import PdfPages as PDF
>
> import matplotlib.font_manager as fm
>
> fontFile = r'C:\Windows\Fonts\ARIALUNI.TTF'
>
> fp1 = fm.FontProperties(fname=fontFile)
>
> reportFile = r'C:\Temp\TestUnicode.pdf'
>
> pdfOutput = PDF(reportFile)
>
> vals = range(100)
>
> PLT.plot(vals, vals, color = "r", linestyle = "-")
>
> mess = u'\u6B63\u5728\u8BFB\u53D6\u6570\u636E...'
>
> PYLAB.xlabel(mess, fontproperties = fp1)
>
> PLT.savefig(pdfOutput, format='pdf')
>
> PLT.close()
>
> pdfOutput.close()
>
> Traceback (most recent call last):
>
> File 
> "C:\Data\CRs10円.1\MemLeak\matplotlib\Scripts\matplotlib_unicode.py", 
> line 27, in <module>
>
> PLT.savefig(pdfOutput, format='pdf')
>
> File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 472, 
> in savefig
>
> return fig.savefig(*args, **kwargs)
>
> File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 
> 1173, in savefig
>
> self.canvas.print_figure(*args, **kwargs)
>
> File "C:\Python27\lib\site-packages\matplotlib\backend_bases.py", 
> line 2027, in print_figure
>
> **kwargs)
>
> File 
> "C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", 
> line 2181, in print_pdf
>
> self.figure.draw(renderer)
>
> File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, 
> in draw_wrapper
>
> draw(artist, renderer, *args, **kwargs)
>
> File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 886, 
> in draw
>
> func(*args)
>
> File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, 
> in draw_wrapper
>
> draw(artist, renderer, *args, **kwargs)
>
> File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1983, 
> in draw
>
> a.draw(renderer)
>
> File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, 
> in draw_wrapper
>
> draw(artist, renderer, *args, **kwargs)
>
> File "C:\Python27\lib\site-packages\matplotlib\axis.py", line 1054, 
> in draw
>
> self.label.draw(renderer)
>
> File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, 
> in draw_wrapper
>
> draw(artist, renderer, *args, **kwargs)
>
> File "C:\Python27\lib\site-packages\matplotlib\text.py", line 587, 
> in draw
>
> ismath=ismath)
>
> File 
> "C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", 
> line 1784, in draw_text
>
> return draw_text_woven(chunks)
>
> File 
> "C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", 
> line 1754, in draw_text_woven
>
> glyph_name = font.get_glyph_name(gind)
>
> RuntimeError: Face has no glyph names
>
> PS. I cannot use a different backend.
>
>
>
> ------------------------------------------------------------------------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
1 message has been excluded from this view by a project administrator.

Showing results of 28

1 2 > >> (Page 1 of 2)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /