switching rc files (and discussion of styles)

Hey everyone,

I wanted to highlight Matthew Emmett's (memmett) PR in progress [1] that
brings the ability to switch between rcParams.

Matthew's implementation started with just being able to read in and use
an rcParam file, and I suggested the idea of having a context manager,
that would allow you to do something like:

  with rc_context(fname):
      plt.plot()
      ...

and have the rcParams restored outside of the context.

I know there have been a few threads (can't find links now for some
reason) and in-person discussions in the past about having this kind of
ability in matplotlib, and having an idea of "styles", and Tony Yu
implemented a variant of this on top of matplotlib in mpltools [2], but
I wanted to ping the list here for other ideas and feelings about such
functionality (if anyone can find pointers to previous discussions, that
would be very welcome).

1. https://github.com/matplotlib/matplotlib/pull/861
2. https://github.com/tonysyu/mpltools

best,

···

--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

Such a feature would clean up the test code considerably.

Ben Root

···

On Fri, May 11, 2012 at 4:17 PM, Paul Ivanov <pivanov314@…149…> wrote:

Hey everyone,

I wanted to highlight Matthew Emmett’s (memmett) PR in progress [1] that

brings the ability to switch between rcParams.

Matthew’s implementation started with just being able to read in and use

an rcParam file, and I suggested the idea of having a context manager,

that would allow you to do something like:

with rc_context(fname):

  plt.plot()

  ...

and have the rcParams restored outside of the context.

I know there have been a few threads (can’t find links now for some

reason) and in-person discussions in the past about having this kind of

ability in matplotlib, and having an idea of “styles”, and Tony Yu

implemented a variant of this on top of matplotlib in mpltools [2], but

I wanted to ping the list here for other ideas and feelings about such

functionality (if anyone can find pointers to previous discussions, that

would be very welcome).

  1. https://github.com/matplotlib/matplotlib/pull/861

  2. https://github.com/tonysyu/mpltools

best,

Paul Ivanov

314 address only used for lists, off-list direct email at:

http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

Hey everyone,

I wanted to highlight Matthew Emmett’s (memmett) PR in progress [1] that

brings the ability to switch between rcParams.

Matthew’s implementation started with just being able to read in and use

an rcParam file, and I suggested the idea of having a context manager,

that would allow you to do something like:

with rc_context(fname):

  plt.plot()

  ...

and have the rcParams restored outside of the context.

I know there have been a few threads (can’t find links now for some

reason) and in-person discussions in the past about having this kind of

ability in matplotlib, and having an idea of “styles”, and Tony Yu

implemented a variant of this on top of matplotlib in mpltools [2], but

I wanted to ping the list here for other ideas and feelings about such

functionality (if anyone can find pointers to previous discussions, that

would be very welcome).

  1. https://github.com/matplotlib/matplotlib/pull/861

  2. https://github.com/tonysyu/mpltools

You will need Python 2.5 or later to use the ‘with’ statement. I think that is already a requirement of matplotlib, and this page–which says 2.4–is not up to date:
http://matplotlib.sourceforge.net/users/installing.html

I’m sure the minimum version of numpy given there (1.1) is also wrong.

Warren

···

On Fri, May 11, 2012 at 3:17 PM, Paul Ivanov <pivanov314@…149…> wrote:

best,

Paul Ivanov

314 address only used for lists, off-list direct email at:

http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7


Live Security Virtual Conference

Exclusive live event will cover all the ways today’s security and

threat landscape has changed and how IT managers can respond. Discussions

will include endpoint security, mobile security and the latest in malware

threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


Matplotlib-devel mailing list

Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Thanks for pinging me on the PR, Paul. Both the original PR and the addition of the context manager are great ideas.

Just to clarify, what I implemented in mpltools was a sort-of stylesheet that can be easily accessed (i.e. you don’t have to remember the path, just the name; and if you forget that, it’s listed in a module attribute). But, I ended up using ConfigObj to parse the rc file instead of using matplotlib’s parser. One major disadvantage of that approach is that ConfigObj uses a different syntax than matplotlib’s rc parameters. In this sense, the PR would help greatly to fix this discrepancy.

Unfortunately, the PR doesn’t completely fulfill my needs. I wanted to allow multiple stylesheets to be declared in a single file; this means I’d need to plug into the loop that iterates over the lines of the file. I can push in that direction on the PR, but I don’t want to do that unless people think this would be more-generally useful.

-Tony

···

On Fri, May 11, 2012 at 4:20 PM, Benjamin Root <ben.root@…553…> wrote:

On Fri, May 11, 2012 at 4:17 PM, Paul Ivanov <pivanov314@…149…> wrote:

Hey everyone,

I wanted to highlight Matthew Emmett’s (memmett) PR in progress [1] that

brings the ability to switch between rcParams.

Matthew’s implementation started with just being able to read in and use

an rcParam file, and I suggested the idea of having a context manager,

that would allow you to do something like:

with rc_context(fname):

  plt.plot()

  ...

and have the rcParams restored outside of the context.

I know there have been a few threads (can’t find links now for some

reason) and in-person discussions in the past about having this kind of

ability in matplotlib, and having an idea of “styles”, and Tony Yu

implemented a variant of this on top of matplotlib in mpltools [2], but

I wanted to ping the list here for other ideas and feelings about such

functionality (if anyone can find pointers to previous discussions, that

would be very welcome).

  1. https://github.com/matplotlib/matplotlib/pull/861

  2. https://github.com/tonysyu/mpltools

best,

Paul Ivanov

314 address only used for lists, off-list direct email at:

http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

Such a feature would clean up the test code considerably.

Ben Root

The minimum requirement of the 1.1 series is still Python 2.4,
believe it or not, though I’m not sure practically what the minimum
numpy is.

The next major release (which will include Python 3 support) bumps

the minimum requirement up to Python 2.6.

Mike
···

http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/Matplotlib-devel@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-devel

The minimum requirement of the 1.1 series is still Python 2.4,

believe it or not, though I’m not sure practically what the minimum
numpy is.

It is at least 1.4; see this thread:
http://old.nabble.com/Upgraded-to-1.1.0,-now-only-line-graphs-work!-td32833484.html

Warren

···

On Fri, May 11, 2012 at 4:45 PM, Michael Droettboom <mdroe@…31…> wrote:

The next major release (which will include Python 3 support) bumps

the minimum requirement up to Python 2.6.

Mike




On 05/11/2012 05:32 PM, Warren Weckesser wrote:
    On Fri, May 11, 2012 at 3:17 PM, Paul > > Ivanov <pivanov314@...149...> > >         wrote:

Hey everyone,

      I wanted to highlight Matthew Emmett's (memmett) PR in

progress [1] that

      brings the ability to switch between rcParams.



      Matthew's implementation started with just being able to read

in and use

      an rcParam file, and I suggested the idea of having a context

manager,

      that would allow you to do something like:



       with rc_context(fname):

           plt.plot()

           ...



      and have the rcParams restored outside of the context.



      I know there have been a few threads (can't find links now for

some

      reason) and in-person discussions in the past about having

this kind of

      ability in matplotlib, and having an idea of "styles", and

Tony Yu

      implemented a variant of this on top of matplotlib in mpltools

[2], but

      I wanted to ping the list here for other ideas and feelings

about such

      functionality (if anyone can find pointers to previous

discussions, that

      would be very welcome).



      1. [https://github.com/matplotlib/matplotlib/pull/861](https://github.com/matplotlib/matplotlib/pull/861)

      2. [https://github.com/tonysyu/mpltools](https://github.com/tonysyu/mpltools)
      You will need Python 2.5 or later to use the 'with'

statement. I think that is already a requirement of
matplotlib, and this page–which says 2.4–is not up to date:

          [http://matplotlib.sourceforge.net/users/installing.html](http://matplotlib.sourceforge.net/users/installing.html)


      I'm sure the minimum version of numpy given there (1.1) is

also wrong.

      Warren

best,

      --

      Paul Ivanov

      314 address only used for lists,  off-list direct email at:

      [http://pirsquared.org](http://pirsquared.org) | GPG/PGP key id:

0x0F3E28F7


      Live Security Virtual Conference

      Exclusive live event will cover all the ways today's security

and

      threat landscape has changed and how IT managers can respond.

Discussions

      will include endpoint security, mobile security and the latest

in malware

      threats. [http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/](http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/)

      _______________________________________________

      Matplotlib-devel mailing list

      Matplotlib-devel@lists.sourceforge.net

      [https://lists.sourceforge.net/lists/listinfo/matplotlib-devel](https://lists.sourceforge.net/lists/listinfo/matplotlib-devel)
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. [http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/](http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/)
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
[https://lists.sourceforge.net/lists/listinfo/matplotlib-devel](https://lists.sourceforge.net/lists/listinfo/matplotlib-devel)

Live Security Virtual Conference

Exclusive live event will cover all the ways today’s security and

threat landscape has changed and how IT managers can respond. Discussions

will include endpoint security, mobile security and the latest in malware

threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


Matplotlib-devel mailing list

Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

The numpy requirement is whichever one introduced no.nextafter(). I beleive that is 1.4.

Ben Root

···

On Friday, May 11, 2012, Michael Droettboom wrote:

The minimum requirement of the 1.1 series is still Python 2.4,

believe it or not, though I’m not sure practically what the minimum
numpy is.

The next major release (which will include Python 3 support) bumps

the minimum requirement up to Python 2.6.

Mike

Right, this was my working assumption when I made the 'with' statement
suggestion. Since it's a new feature, it won't make it into the 1.1.x
series, and in the next major relase (>= py2.6) we can safely use
context managers.

best

···

On Fri, May 11, 2012 at 2:45 PM, Michael Droettboom <mdroe@...31...> wrote:

The next major release (which will include Python 3 support) bumps the
minimum requirement up to Python 2.6.

--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

Hello,

This is a good idea indeed. Especially, when one creates plots for presentations and papers. Usually, I make ticks, ticklabels, axes labels, line widths, marker sizes as large as possible (within reasonable limits) to make them more readable for presentation purposes. However, the same element sizes don’t look very pretty when I create the same plots for paper or vice versa. The solution is either keep modify two rc files or adjust one rc file accordingly for each plotting style.

Could the syntax be simplfied a bit? Say rather than using that with statement and the extra 4 spaces, can it be just a one simple liner like matplotlib.rcuse(mpl_paper.rc) or matplotlib.rcuse(mpl_presentation.rc)?

···

On Fri, May 11, 2012 at 2:17 PM, Paul Ivanov <pivanov314@…149…> wrote:

Hey everyone,

I wanted to highlight Matthew Emmett’s (memmett) PR in progress [1] that

brings the ability to switch between rcParams.

Matthew’s implementation started with just being able to read in and use

an rcParam file, and I suggested the idea of having a context manager,

that would allow you to do something like:

with rc_context(fname):

  plt.plot()

  ...

and have the rcParams restored outside of the context.

I know there have been a few threads (can’t find links now for some

reason) and in-person discussions in the past about having this kind of

ability in matplotlib, and having an idea of “styles”, and Tony Yu

implemented a variant of this on top of matplotlib in mpltools [2], but

I wanted to ping the list here for other ideas and feelings about such

functionality (if anyone can find pointers to previous discussions, that

would be very welcome).

  1. https://github.com/matplotlib/matplotlib/pull/861

  2. https://github.com/tonysyu/mpltools

best,

Paul Ivanov

314 address only used for lists, off-list direct email at:

http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7


Live Security Virtual Conference

Exclusive live event will cover all the ways today’s security and

threat landscape has changed and how IT managers can respond. Discussions

will include endpoint security, mobile security and the latest in malware

threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


Matplotlib-devel mailing list

Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Gökhan

Hello,

This is a good idea indeed. Especially, when one creates plots for presentations and papers. Usually, I make ticks, ticklabels, axes labels, line widths, marker sizes as large as possible (within reasonable limits) to make them more readable for presentation purposes. However, the same element sizes don’t look very pretty when I create the same plots for paper or vice versa. The solution is either keep modify two rc files or adjust one rc file accordingly for each plotting style.

Could the syntax be simplfied a bit? Say rather than using that with statement and the extra 4 spaces, can it be just a one simple liner like matplotlib.rcuse(mpl_paper.rc) or matplotlib.rcuse(mpl_presentation.rc)?

I believe that’s what the rc_file function does in the PR, so both use cases are possible. I think it makes sense to allow both.

Cheers,

-Tony

···

On Sat, May 12, 2012 at 3:11 PM, Gökhan Sever <gokhansever@…149…> wrote:

On Fri, May 11, 2012 at 2:17 PM, Paul Ivanov <pivanov314@…149…> wrote:

Hey everyone,

I wanted to highlight Matthew Emmett’s (memmett) PR in progress [1] that

brings the ability to switch between rcParams.

Matthew’s implementation started with just being able to read in and use

an rcParam file, and I suggested the idea of having a context manager,

that would allow you to do something like:

with rc_context(fname):

  plt.plot()

  ...

and have the rcParams restored outside of the context.

I know there have been a few threads (can’t find links now for some

reason) and in-person discussions in the past about having this kind of

ability in matplotlib, and having an idea of “styles”, and Tony Yu

implemented a variant of this on top of matplotlib in mpltools [2], but

I wanted to ping the list here for other ideas and feelings about such

functionality (if anyone can find pointers to previous discussions, that

would be very welcome).

  1. https://github.com/matplotlib/matplotlib/pull/861

  2. https://github.com/tonysyu/mpltools

best,

Paul Ivanov

314 address only used for lists, off-list direct email at:

http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7


Live Security Virtual Conference

Exclusive live event will cover all the ways today’s security and

threat landscape has changed and how IT managers can respond. Discussions

will include endpoint security, mobile security and the latest in malware

threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


Matplotlib-devel mailing list

Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Gökhan


Live Security Virtual Conference

Exclusive live event will cover all the ways today’s security and

threat landscape has changed and how IT managers can respond. Discussions

will include endpoint security, mobile security and the latest in malware

threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


Matplotlib-devel mailing list

Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel