1

in MATLAB you can edit, if needed, figure files (.fig) - is there a similar functionality using pylab?

I can create the image I need but it comes out as .png that I have no control over - if I could sligthly edit it (e.g. to move legend to the side, or modify labels) would be great

Zoyd
  • 3,449
  • 1
  • 18
  • 27
Dimitris
  • 425
  • 1
  • 9
  • 21
  • To modify color `matplotlib.rc(labelcolor='w')`. To write it do `from matplotlib import pyplot` then `pyplot.xlabel('X axis text')`. Same for the y axis. To change the type of file, I do not know if it is possible. – Arthur Julião Feb 05 '13 at 15:15
  • at the moment there is nothing like figure files. However if you save as PDF, should be possible to at least modify labels with external applications. I don't know if it possible to obtain something similar to what you want using [pickle](http://docs.python.org/2/library/pickle.html) – Francesco Montesano Feb 05 '13 at 15:16
  • thanks guys, is there an option to save as .svg? – Dimitris Feb 05 '13 at 15:32
  • Yes, when you save the plot manually, you can choose different output formats. – Jan Feb 05 '13 at 15:34
  • Btw. what you are asking for is a subset of the question http://stackoverflow.com/questions/4348733/saving-interactive-matplotlib-figures – Jan Feb 05 '13 at 15:37
  • OK got it -was easy enough (just add the proper extension) – Dimitris Feb 05 '13 at 15:43
  • thanks for the link - I missed it (I guess it depends on how you search for questions) – Dimitris Feb 05 '13 at 15:44

1 Answers1

0

If you want to save your plot and edit it later, you should try the hints given in this thread

If your plot is still active in a [I]python shell, you can edit all properties and make a redraw. The following example is for moving the legend from default location to right upper corner after examination.

In [51]: import numpy as np

In [52]: import pylab as pl

In [53]: v = np.arange(10)

In [54]: pl.figure(1)
Out[54]: <matplotlib.figure.Figure at 0x253a250>

In [55]: # if needed, use pl.figure(1) again to make it active

In [56]: pl.plot(v)
Out[56]: [<matplotlib.lines.Line2D at 0x456a450>]

In [60]: pl.legend('v')
Out[60]: <matplotlib.legend.Legend at 0x4591150>

In [61]: pl.show(block=False)

In [62]: # keyword block=False to issue further commands

In [63]: pl.legend('v',loc=2)
Out[63]: <matplotlib.legend.Legend at 0x45962d0>

In [64]: pl.show(block=False)

In [67]: # now the legend is in the upper right corner
Community
  • 1
  • 1
Jan
  • 4,932
  • 1
  • 26
  • 30
  • thanks - this is a good suggestion that I could use - but when I am using the block=false keyword the image does not appear (I just tried your example) - I would like to see the image before editing it - am I doing something wrong? – Dimitris Feb 06 '13 at 22:10
  • How did you execute this script? It should work, when you are in an Ipython shell. – Jan Feb 07 '13 at 07:14