[Matplotlib-users] problem with a umlaut

2013-05-15 Thread Ojala Janne
I have a weird problem with Unicode strings. I am using windows 7 with
Python 2.7.2 64 bit, and matplotlib 1.2.1 (package from Unofficial Windows
Binaries at http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib ).

When i run:
-*- coding: utf-8 -*-
import matplotlib.pyplot as plt

fig = plt.figure( )

ax = fig.add_subplot(111)
ax.hist([1,2,3,4,5,6,7,8,9,10], bins=range(1,11) )

plt.ylabel(u'ä')
fig.savefig('test.eps')

I get a crash:

>pythonw -u "bugtest.py"
>Exit code: -1073740777

but if i modify my code to read:
-*- coding: utf-8 -*-
import matplotlib.pyplot as plt

fig = plt.figure( )

ax = fig.add_subplot(111)
ax.hist([1,2,3,4,5,6,7,8,9,10], bins=range(1,11) )

plt.ylabel(u'äł')
fig.savefig('test.eps')

Then no longer crashes. Why is it that "a umlaut" alone crashes
but when the string contains a "l stroke" character the Unicode string
behaves fine. In both cases it works fine if I show the plot but not when
I write eps either in code or when saving.


--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] problem with a umlaut

2013-05-15 Thread Alexander Eberspaecher
On Wed, 15 May 2013 10:40:47 +
Ojala Janne  wrote:

['ä' Umlaut]
> >pythonw -u "bugtest.py"
> >Exit code: -1073740777

My installation (Python 2.6.6, MPL 1.2.1) is a bit more helpful with
error messages:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in
position 269: ordinal not in range(128)

A similar error is raised with the other character you suggested.

Unfortunately, I do not know about MPL's limitations related to unicode
labels. I use "text.usetex : True" in my matplotlibrc.

Regards

Alex
-- 
Alexander Eberspächer
Theorie der Kondensierten Materie I
Otto-von-Guericke-Universität Magdeburg
Fon: +49 391 67 11339

--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] text with gridspec

2013-05-15 Thread Claus Haslauer
Hi,
I am trying to produce a set of plots using grispec. There should be an images 
shown in each of the axes (using imshow) except in one of the axes, where I 
want to show/plot some text. However, the text seems to be too long to be 
displayed in one line. Is there a way to print it in something like a text box? 

I created a minimal example (see below). 'circle.png' can be seen as a 
placeholder for some png file.
There are two examples I found on stackoverflow. But I am not sure how they 
could be applicable here

http://stackoverflow.com/questions/5777576/is-there-a-way-of-drawing-a-caption-box-in-matplotlib
http://stackoverflow.com/questions/4018860/text-box-in-matplotlib

I can not / do not want to make a string variable with three quotation marks 
(docstring), because I am reading the text from a bigger ascii file.

Also, I am not sure if gridspec is the best way to do this.
Thanks for pointers!

# --- start script

import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec


def main():
"""
goal is to show justified text in one axes of matplotlib
"""
plt.close('all')
fig = plt.figure(figsize=(5, 10))
plt.subplots_adjust(left=0.1, right=0.9, top=0.95, bottom=0.1)

n_rows = 5
outer_grid = gridspec.GridSpec(n_rows, 2 )# ,wspace=0.0, hspace=0.0

lst_files = [ 'circle.png'
, 'circle.png'
, 'circle.png'
, 'circle.png'
, 'text'
, 'circle.png'
, 'circle.png'
, 'circle.png'
, 'circle.png']

for cur_map_id, cur_map_file in enumerate(lst_files):

cur_row = (cur_map_id % n_rows)
if cur_map_id / n_rows == 0:
cur_column = 0
else:
cur_column = 1

# preparation: no axes
ax = plt.subplot(outer_grid[cur_row, cur_column], frameon=False)
ax.axes.get_yaxis().set_visible(False)
ax.axes.get_xaxis().set_visible(False)

# fix for the fact that the fourth entry is text and not in tmp_lst_imgs
if cur_map_id > 4: 
cur_map_id = cur_map_id - 1

# the actual plotting
if cur_map_file == 'text':
lorem = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, 
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad 
minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea 
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit 
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat 
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
ax.text(0.05, 0.9, lorem, size=6)
else:
print cur_map_id
im = plt.imread(cur_map_file)
ax.imshow(im)
ax.set_title(cur_map_file, size=6)
fig.add_subplot(ax)

plt.savefig('blah.png', dpi=300)
print "done!"

if __name__ == '__main__':
main() --
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] problem with a umlaut

2013-05-15 Thread Ojala Janne
>>  I use "text.usetex : True" in my matplotlibrc.

It works if I force it to tex, its still a nasty bug of somekind. What I
would like to know what changes in the processing when you have
both those characters present? Does it fallback to tex use at some
point? If so why does it not fallback for ä automatically.
--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] problem with a umlaut

2013-05-15 Thread Michael Droettboom

Which backend are you using?  I can't reproduce.  Does

https://github.com/matplotlib/matplotlib/blob/master/examples/text_labels_and_annotations/unicode_demo.py

work for you?

Mike

On 05/15/2013 06:40 AM, Ojala Janne wrote:

I have a weird problem with Unicode strings. I am using windows 7 with
Python 2.7.2 64 bit, and matplotlib 1.2.1 (package from Unofficial Windows
Binaries at http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib ).

When i run:
 -*- coding: utf-8 -*-
 import matplotlib.pyplot as plt

 fig = plt.figure( )

 ax = fig.add_subplot(111)
 ax.hist([1,2,3,4,5,6,7,8,9,10], bins=range(1,11) )

 plt.ylabel(u'ä')
 fig.savefig('test.eps')

I get a crash:


pythonw -u "bugtest.py"
Exit code: -1073740777

but if i modify my code to read:
 -*- coding: utf-8 -*-
 import matplotlib.pyplot as plt

 fig = plt.figure( )

 ax = fig.add_subplot(111)
 ax.hist([1,2,3,4,5,6,7,8,9,10], bins=range(1,11) )

 plt.ylabel(u'äł')
 fig.savefig('test.eps')

Then no longer crashes. Why is it that "a umlaut" alone crashes
but when the string contains a "l stroke" character the Unicode string
behaves fine. In both cases it works fine if I show the plot but not when
I write eps either in code or when saving.


--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] problem with a umlaut

2013-05-15 Thread Ojala Janne

>> Which backend are you using?  I can't reproduce.  Does

>>https://github.com/matplotlib/matplotlib/blob/master/examples/text_labels_and_annotations/unicode_demo.py

>> work for you?

The bug only happens if I try to save the figure as EPS. So I suppose that
then means its a cairo back end (happens also if I force cairo). So that means
as written the code works fine but if i try to make publishable quality output
by saving as EPS (a raster image is not suitable), it crashes.

But it again works if I add any character thats so weird that ist on a n 
extended
 unicode block then all characters seem to be handled correctly. Even the ones
that previously crashed.
--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] problem with a umlaut

2013-05-15 Thread Christoph Gohlke

On 5/15/2013 1:55 PM, Ojala Janne wrote:



Which backend are you using?  I can't reproduce.  Does



https://github.com/matplotlib/matplotlib/blob/master/examples/text_labels_and_annotations/unicode_demo.py




work for you?


The bug only happens if I try to save the figure as EPS. So I suppose that
then means its a cairo back end (happens also if I force cairo). So that
means
as written the code works fine but if i try to make publishable quality
output
by saving as EPS (a raster image is not suitable), it crashes.

But it again works if I add any character thats so weird that ist on a n
extended
  unicode block then all characters seem to be handled correctly. Even
the ones
that previously crashed.



I can reproduce the crash on Python 2.7, 32 and 64 bit. Python 2.6 and 
3.3 appear to work. The call stack is attached. The crash is in 
ttfont_add_glyph_dependencies() at 



Christoph



msvcr90.dll!__crt_debugger_hook(int _Reserved=0)  Line 65   C
msvcr90.dll!_invoke_watson(const wchar_t * 
pszExpression=0x0022e750, const wchar_t * 
pszFunction=0x798363d3, const wchar_t * pszFile=0x05ed9ddc, 
unsigned int nLine=109701576, unsigned __int64 pReserved=0)  Line 233  C++
msvcr90.dll!_invalid_parameter(const wchar_t * 
pszExpression=0x05f649a8, const wchar_t * 
pszFunction=0x05b8ce88, const wchar_t * pszFile=0x0022e708, 
unsigned int nLine=2288096, unsigned __int64 pReserved=0)  Line 115C++
msvcr90.dll!_invalid_parameter_noinfo()  Line 126   C++
ttconv.pyd!std::_Vector_const_iterator 
>::operator*()  Line 106 C++
ttconv.pyd!std::_Vector_iterator >::operator*() 
 Line 340   C++
>   ttconv.pyd!ttfont_add_glyph_dependencies(TTFONT * 
> font=0x0022e8c0, std::vector > & 
> glyph_ids=[13](17,19,20,21,22,23,24,25,26,27,28,36,174))  Line 703 + 0xd 
> bytes   C++
ttconv.pyd!read_font(const char * filename=0x05f7fa60, 
font_type_enum target_type=PS_TYPE_3, std::vector > & 
glyph_ids=[13](17,19,20,21,22,23,24,25,26,27,28,36,174), TTFONT & font={...})  
Line 1326   C++
ttconv.pyd!insert_ttfont(const char * filename=0x05f7fa60, 
TTStreamWriter & stream={...}, font_type_enum target_type=PS_TYPE_3, 
std::vector > & 
glyph_ids=[13](17,19,20,21,22,23,24,25,26,27,28,36,174))  Line 1336 C++
ttconv.pyd!convert_ttf_to_ps(_object * self=0x, _object 
* args=0x05f649a8, _object * kwds=0x)  Line 149 + 0x1f 
bytesC++
python27.dll!PyCFunction_Call(_object * func=0x0004, 
_object * arg=0x01d57760, _object * kw=0x05b8ce88)  Line 85 + 
0x8 bytesC
python27.dll!call_function(_object * * * pp_stack=0x, 
int oparg=131)  Line 4021 + 0xaf bytesC
python27.dll!PyEval_EvalFrameEx(_frame * f=0x05ceddf8, int 
throwflag=99512536)  Line 2670   C
python27.dll!PyEval_EvalCodeEx(PyCodeObject * co=0x05f725b0, 
_object * globals=0x0009, _object * locals=0x0001, 
_object * * args=0x, int argcount=9, _object * * 
kws=0x05bb31a0, int kwcount=1, _object * * defs=0x05f6e3c0, int 
defcount=6, _object * closure=0x)  Line 3253 + 0xa bytes   C
python27.dll!function_call(_object * func=0x05f7c588, _object * 
arg=0x05b729a8, _object * kw=0x0009)  Line 531 + 0x3b bytes 
C
python27.dll!PyObject_Call(_object * func=0x05b729a8, _object * 
arg=0x05fd7798, _object * kw=0x)  Line 2530 C
python27.dll!ext_do_call(_object * func=0x05f7c588, _object * * 
* pp_stack=0x0002, int flags=9384, int na=9, int nk=0)  Line 
4334 + 0xe bytes   C
python27.dll!PyEval_EvalFrameEx(_frame * f=0x05b20d18, int 
throwflag=95362448)  Line 2708   C
python27.dll!PyEval_EvalCodeEx(PyCodeObject * co=0x05f72430, 
_object * globals=0x0003, _object * locals=0x0005, 
_object * * args=0x05f63c50, int argcount=3, _object * * 
kws=0x05f7a1e0, int kwcount=5, _object * * defs=0x, int 
defcount=0, _object * closure=0x)  Line 3253 + 0xa bytes   C
python27.dll!function_call(_object * func=0x05f7c518, _object * 
arg=0x01e7a750, _object * kw=0x0009)  Line 531 + 0x3b bytes 
C
python27.dll!PyObject_Call(_object * func=0x01e7a750, _object * 
arg=0x05fd5818, _object * kw=0x01d61048)  Line 2530 C
python27.dll!ext_do_call(_object * func=0x05f7c518, _object * * 
* pp_stack=0x0003, int flags=100268584, int na=3, int nk=0)

[Matplotlib-users] missing ticks on inverted log axis

2013-05-15 Thread gaspra
Hi, I am having troubles to correctly make a figure with inverted log axis.
This is what I am doing:

import numpy as np
import matplotlib.pyplot as plt

y=np.linspace(-90,90,20)
z=np.arange(1,1.e4, 200)

c=y.reshape(20,1)*z.reshape(1,len(z))

fig,ax=plt.subplots()
plt.pcolor(y,z,c.transpose())
ax.set_yscale('log')
ax.invert_yaxis()

The problem is that the ticks of y axis is not displayed correctly once I
invert the y axis. It shows the tick at 1000. All other ticks such as 100,
10 and 1 are missing.  Am I doing something wrong or is this a bug in
matplotlib?

Thanks for your help.





--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/missing-ticks-on-inverted-log-axis-tp41063.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] missing ticks on inverted log axis

2013-05-15 Thread Paul Hobson
On Wed, May 15, 2013 at 3:48 PM, gaspra  wrote:

> Hi, I am having troubles to correctly make a figure with inverted log axis.
> This is what I am doing:
>
> import numpy as np
> import matplotlib.pyplot as plt
>
> y=np.linspace(-90,90,20)
> z=np.arange(1,1.e4, 200)
>
> c=y.reshape(20,1)*z.reshape(1,len(z))
>
> fig,ax=plt.subplots()
> plt.pcolor(y,z,c.transpose())
> ax.set_yscale('log')
> ax.invert_yaxis()
>
> The problem is that the ticks of y axis is not displayed correctly once I
> invert the y axis. It shows the tick at 1000. All other ticks such as 100,
> 10 and 1 are missing.  Am I doing something wrong or is this a bug in
> matplotlib?
>
> Thanks for your help.
>

This works fine on my system:
 In [3]: np.version.full_version

Out[3]: '1.7.1'


In [5]: matplotlib.__version__

Out[5]: '1.2.1'


Not sure what the issue could be.

-p
--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] missing ticks on inverted log axis

2013-05-15 Thread gaspra
Paul Hobson-2 wrote
> This works fine on my system:
>  In [3]: np.version.full_version
> 
> Out[3]: '1.7.1'
> 
> 
> In [5]: matplotlib.__version__
> 
> Out[5]: '1.2.1'
> 
> 
> Not sure what the issue could be.
> 
> -p

Hi Paul,

Thanks for the reply. I am using np version 1.7.1 and matplotlib version
1.3.x. In fact I have the same problem with matplotlib version 1.2.1. Could
it be the problem with Mac OS (mountain lion 10.8.3)?

Yuan




--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/missing-ticks-on-inverted-log-axis-tp41063p41065.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] problem with a umlaut

2013-05-15 Thread Michael Droettboom

I've created an issue in the tracker for this:

https://github.com/matplotlib/matplotlib/issues/2016

Mike

On 05/15/2013 06:26 PM, Christoph Gohlke wrote:

On 5/15/2013 1:55 PM, Ojala Janne wrote:



Which backend are you using?  I can't reproduce.  Does


https://github.com/matplotlib/matplotlib/blob/master/examples/text_labels_and_annotations/unicode_demo.py 

 




work for you?


The bug only happens if I try to save the figure as EPS. So I suppose 
that

then means its a cairo back end (happens also if I force cairo). So that
means
as written the code works fine but if i try to make publishable quality
output
by saving as EPS (a raster image is not suitable), it crashes.

But it again works if I add any character thats so weird that ist on a n
extended
  unicode block then all characters seem to be handled correctly. Even
the ones
that previously crashed.



I can reproduce the crash on Python 2.7, 32 and 64 bit. Python 2.6 and 
3.3 appear to work. The call stack is attached. The crash is in 
ttfont_add_glyph_dependencies() at 



Christoph





--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d


___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users