SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Gert-Jan <gj_...@ho...> - 2009年04月29日 08:51:37
Hey there,
In my application I'd like to export plots as Enhanced Metafiles (.emf).
After finding out that saving created plots as EMF generates an error, I 
http://www.nabble.com/EMF-export-doesn%27t-work-td22618867.html read that
emf is no longer supported . Then I tried to 
http://www.nabble.com/How-to-add-a-new-backend--td20089848.html#a20091178
manually enable exporting as EMF , but matplit.use('emf') generates a
NotImplementedError.
So, I'd like to know if someone happens to know of a simple method to
reimplement the support for EMF files.
Thanks in advance for your time and effort!
Cheers,
Gert-Jan
-- 
View this message in context: http://www.nabble.com/Manually-enable-export-as-EMF-tp23293186p23293186.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: John H. <jd...@gm...> - 2009年04月30日 20:44:45
Attachments: backend_emf.py
On Wed, Apr 29, 2009 at 3:51 AM, Gert-Jan <gj_...@ho...> wrote:
>
> Hey there,
>
> In my application I'd like to export plots as Enhanced Metafiles (.emf).
> After finding out that saving created plots as EMF generates an error, I
> http://www.nabble.com/EMF-export-doesn%27t-work-td22618867.html read that
> emf is no longer supported . Then I tried to
> http://www.nabble.com/How-to-add-a-new-backend--td20089848.html#a20091178
> manually enable exporting as EMF , but matplit.use('emf') generates a
> NotImplementedError.
>
> So, I'd like to know if someone happens to know of a simple method to
> reimplement the support for EMF files.
>
> Thanks in advance for your time and effort!
The syntax is
 matplotlib.use('module://backend_emf')
if backend_emf.py is in your PYTHONPATH. There is no guarantee that this
module will work with your version of matplotlib, so you may need to do some
work porting it to the latest backend API.
JDH
From: Gert-Jan <gj_...@ho...> - 2009年05月01日 09:31:46
Hello again,
Thanks for the reply! I did some more testing, but I couldn't get it to work
yet. However, during the testing, I got the idea that I was wrong about what
backends do; it appears they are only used for creating plots, not for
saving them. For example:
> #!/usr/bin/env python
> 
> import matplotlib
> matplotlib.use('module://backend_emf')
> from pylab import *
> 
> x = [0,1,2,3]
> y = [4,3,2,1]
> 
> figure()
> plot(x,y)
> savefig('C:\\test.emf')
> 
This still results in a NotImplemented error. Trying to save as another file
type (savefig(C':\\test.pdf') for example) won't work anymore, either.
Trying to save as PDF, for example, gives this error message:
> ValueError: Format "pdf" is not supported.
> Supported formats: emf.
> 
Basically, what I'd like to have is that, when the user views the plot and
presses the save button, the user can select 'Enhanced Metafile (*.emf)'
from the file type list and save as EMF.
Well, thanks for the help so far. I hope there is a solution for this.
Otherwise I think I'll revert to an older version.
PS. It appears as though the Matplotlib creators have forgotten to remove
EMF from the file type list, as it's still there.
Also, there appears to be a bug when saving files, as the selection from the
file type list is ignored and the file is saved as PNG instead, unless you
manually add another extension in the name.
-- 
View this message in context: http://www.nabble.com/Manually-enable-export-as-EMF-tp23293186p23330477.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Michael D. <md...@st...> - 2009年05月01日 12:34:43
Gert-Jan wrote:
> Hello again,
>
> Thanks for the reply! I did some more testing, but I couldn't get it to work
> yet. However, during the testing, I got the idea that I was wrong about what
> backends do; it appears they are only used for creating plots, not for
> saving them. For example:
>
>
>
> 
>> #!/usr/bin/env python
>>
>> import matplotlib
>> matplotlib.use('module://backend_emf')
>> from pylab import *
>>
>> x = [0,1,2,3]
>> y = [4,3,2,1]
>>
>> figure()
>> plot(x,y)
>> savefig('C:\\test.emf')
>>
>> 
>
> This still results in a NotImplemented error. Trying to save as another file
> type (savefig(C':\\test.pdf') for example) won't work anymore, either.
> Trying to save as PDF, for example, gives this error message:
>
>
>
> 
>> ValueError: Format "pdf" is not supported.
>> Supported formats: emf.
>>
>> 
>
> Basically, what I'd like to have is that, when the user views the plot and
> presses the save button, the user can select 'Enhanced Metafile (*.emf)'
> from the file type list and save as EMF.
> 
Can you be more specific about why that doesn't work?
> Well, thanks for the help so far. I hope there is a solution for this.
> Otherwise I think I'll revert to an older version.
>
> PS. It appears as though the Matplotlib creators have forgotten to remove
> EMF from the file type list, as it's still there.
> 
Yes -- that was an oversight.
> Also, there appears to be a bug when saving files, as the selection from the
> file type list is ignored and the file is saved as PNG instead, unless you
> manually add another extension in the name.
> 
What GUI backend are you using? That sounds like a bug in how the file 
selection dialog is being used.
Cheers,
Mike
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Gert-Jan <gj_...@ho...> - 2009年05月01日 13:24:42
Michael Droettboom-3 wrote:
> 
> Can you be more specific about why that doesn't work?
> 
Trying to save a plot as, for example, 'image.emf' makes an error message
pop up. This error dialog has the title 'Error saving file', but does not
have any error message in its body.
I hope that is what you mean?
Michael Droettboom-3 wrote:
> 
> What GUI backend are you using? That sounds like a bug in how the file
> selection dialog is being used.
> 
I'm using the Qt4 backend in my application, though the code examples I gave
are created and executed without any GUI backend.
To see this for yourself you could run this example code:
> from pylab import *
> 
> x = [0,1,2,3]
> y = [4,3,2,1]
> 
> figure()
> plot(x,y)
> show()
> 
I'm using the most current version (0.98.5.2) of Matplotlib, just to be
clear about that.
Cheers,
Gert-Jan
-- 
View this message in context: http://www.nabble.com/Manually-enable-export-as-EMF-tp23293186p23333043.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Olivier B. <oli...@er...> - 2009年05月04日 14:49:52
Hi,
I'm new with matplotlib.
I need to make a graph with the X axis represents time in hours and
minutes. My script don't works, I want to display all the values of time
that I have.
I use a list of string like this :
t=['0015', '0030', '0045', '0100', '0115', '0130', '0145', '0200',
'0215', '0230', '0245', '0300', '03
15', '0330', '0345', '0400', '0415', '0430', '0445', '0500', '0515',
'0530', '0545', '0600', '0615',
 '0630', '0645', '0700', '0715', '0730', '0745', '0800', '0815', '0830',
'0845', '0900', '0915', '09
30', '0945', '1000', '1015', '1030', '1045', '1100', '1115', '1130',
'1145', '1200', '1215', '1230',
 '1245', '1300', '1315', '1330', '1345', '1400', '1415']
ax.plot(t, y)
I tried to convert hours and minutes to the base 100 ( , it works but I
can not show on the x-axis the hours, minutes.
I tried to use plot_date, but I don't understand "x and/or y can be a
sequence of dates represented as float days since 0001年01月01日 UTC."
Could you help me, please ?
/olivier
From: Gert-Jan <gj_...@ho...> - 2009年05月07日 09:02:41
Hey all,
I was just hoping anyone could help me further here... it would be highly
appreciated.
Thanks in advance,
Gert-Jan
Olivier Benoist wrote:
> 
> Hi,
> I'm new with matplotlib.
> 
> I need to make a graph with the X axis represents time in hours and
> minutes. My script don't works, I want to display all the values of time
> that I have.
> I use a list of string like this :
> t=['0015', '0030', '0045', '0100', '0115', '0130', '0145', '0200',
> '0215', '0230', '0245', '0300', '03
> 15', '0330', '0345', '0400', '0415', '0430', '0445', '0500', '0515',
> '0530', '0545', '0600', '0615',
> '0630', '0645', '0700', '0715', '0730', '0745', '0800', '0815', '0830',
> '0845', '0900', '0915', '09
> 30', '0945', '1000', '1015', '1030', '1045', '1100', '1115', '1130',
> '1145', '1200', '1215', '1230',
> '1245', '1300', '1315', '1330', '1345', '1400', '1415']
> 
> ax.plot(t, y)
> 
> I tried to convert hours and minutes to the base 100 ( , it works but I
> can not show on the x-axis the hours, minutes.
> I tried to use plot_date, but I don't understand "x and/or y can be a
> sequence of dates represented as float days since 0001年01月01日 UTC."
> 
> Could you help me, please ?
> 
> /olivier
> 
> ------------------------------------------------------------------------------
> Register Now & Save for Velocity, the Web Performance & Operations 
> Conference from O'Reilly Media. Velocity features a full day of 
> expert-led, hands-on workshops and two days of sessions from industry 
> leaders in dedicated Performance & Operations tracks. Use code vel09scf 
> and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
I believe this needs its own thread. =)
-- 
View this message in context: http://www.nabble.com/Manually-enable-export-as-EMF-tp23293186p23422798.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Ryan M. <rm...@gm...> - 2009年05月07日 18:38:29
On Mon, May 4, 2009 at 9:49 AM, Olivier Benoist <
oli...@er...> wrote:
> Hi,
> I'm new with matplotlib.
>
> I need to make a graph with the X axis represents time in hours and
> minutes. My script don't works, I want to display all the values of time
> that I have.
> I use a list of string like this :
> t=['0015', '0030', '0045', '0100', '0115', '0130', '0145', '0200',
> '0215', '0230', '0245', '0300', '03
> 15', '0330', '0345', '0400', '0415', '0430', '0445', '0500', '0515',
> '0530', '0545', '0600', '0615',
> '0630', '0645', '0700', '0715', '0730', '0745', '0800', '0815', '0830',
> '0845', '0900', '0915', '09
> 30', '0945', '1000', '1015', '1030', '1045', '1100', '1115', '1130',
> '1145', '1200', '1215', '1230',
> '1245', '1300', '1315', '1330', '1345', '1400', '1415']
>
> ax.plot(t, y)
>
> I tried to convert hours and minutes to the base 100 ( , it works but I
> can not show on the x-axis the hours, minutes.
> I tried to use plot_date, but I don't understand "x and/or y can be a
> sequence of dates represented as float days since 0001年01月01日 UTC."
>
> Could you help me, please ?
You don't necessarily need to use plot_date. Try this:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter, MultipleLocator
times = ['0015', '0030', '0045', '0100', '0115', '0130', '0145', '0200',
'0215',
 '0230', '0245', '0300', '0315', '0330', '0345', '0400', '0415', '0430',
 '0445', '0500', '0515', '0530', '0545', '0600', '0615', '0630', '0645',
 '0700', '0715', '0730', '0745', '0800', '0815', '0830', '0845', '0900',
 '0915', '0930', '0945', '1000', '1015', '1030', '1045', '1100', '1115',
 '1130', '1145', '1200', '1215', '1230', '1245', '1300', '1315', '1330',
 '1345', '1400', '1415']
# Conver the string time values into the corresponding number of minutes
minutes = np.array([int(t[:2])*60 + int(t[2:]) for t in times])
y = np.random.rand(*minutes.shape)
plt.plot(minutes, y)
ax = plt.gca()
# Set the formatter to take a value in minutes and convert to hour:minute
ax.xaxis.set_major_formatter(FuncFormatter(
 lambda t,p : '%02d:%02d' % (t//60, t%60)))
# Set up placing tick marks every 15 minutes
ax.xaxis.set_major_locator(MultipleLocator(15))
# Used to rotate all of the ticks so that they fit on the plot.
# ha='center' aligns them better to the tick marks
fig = plt.gcf()
fig.autofmt_xdate(rotation=90, ha='center')
plt.show()
Ryan
--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from Norman, Oklahoma, United States
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 によって変換されたページ (->オリジナル) /