Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple way to set figsize for ANY plot #112

Closed
sjobeek opened this issue Feb 25, 2014 · 8 comments · Fixed by #141
Closed

Simple way to set figsize for ANY plot #112

sjobeek opened this issue Feb 25, 2014 · 8 comments · Fixed by #141
Labels

Comments

@sjobeek
Copy link

sjobeek commented Feb 25, 2014

I often find myself doing some quick-and-dirty plotting, and wishing there was a simple, one-step, easy-to-remember way to set the default figsize for all matplotlib plots.

I imagine something very light-weight like sns.set(figsize=(2, 4)) or sns.set_figsize(2, 4).

iPython actually has this already as IPython.core.pylabtools.figsize(sizex, sizey).

I can submit a pull request pretty easily, but I wanted to ask you opinion first.

@mwaskom
Copy link
Owner

mwaskom commented Feb 25, 2014

Any reason you don't want to do mpl.rc("figure", figsize=(9, 4))? I'd generally like to avoid having things that shadow matplotlib functionality without adding anything to it..

@sjobeek
Copy link
Author

sjobeek commented Feb 26, 2014

I see, so like sns.mpl.rc("figure", figsize=(9,4)) would work?

Does this kind of thing work properly in a with block without affecting the rest of your plots like the other sns.set() tools do?

That's not too bad, but it just feels like sns.set() should have a figsize keyword instead of always defaulting to the hard-coded value it uses now. I can understand your reluctance to duplicate functionality all over the place, though.

It's mainly about having something that is easy to remember without needing to google it each time you want to quickly change the size.

@mwaskom
Copy link
Owner

mwaskom commented Feb 26, 2014

Sure you could use matplotlib's provided rc_context function for that.

Though I'm not sure I see much advantage to that over just defining a figure with a specific figuresize if you want a unique deviation from the default.

@sjobeek
Copy link
Author

sjobeek commented Feb 26, 2014

hmm.. so now that I know it exists I suppose I could use an rc_context and directly modify the rc parameters for this kind of stuff, but what I love about seaborn is that it simplifies and streamline things like setting RC parameters or using the rc_context so I don't need to figure out and memorize the syntax for all of that machinery. Seeing "figsize" pop up as a keyword in sns.set() is a heck of a lot more discoverable for your average joe.

I'm sure you're quite familiar with all of that now, but I'm sure there are a lot of people for whom the guts of matplotlib are pretty opaque (myself included). For this example, how did you even know that you needed to use "figure" as the first argument in mpl.rc() in order to set figure size? The documentation I was able to find isn't too helpful: http://matplotlib.org/api/matplotlib_configuration_api.html?highlight=rc#matplotlib.rc

I don't think it's too unreasonable to provide a simplified interface to some of the more common rc parameters, but anyways that's enough complaining from me =)

@mwaskom
Copy link
Owner

mwaskom commented Mar 4, 2014

For this example, how did you even know that you needed to use "figure" as the first argument in mpl.rc() in order to set figure size?

Well, I take this as a mostly rhetorical question, but if your'e curious the first argument is a group from the rc parameters and the keyword arguments are parameter/value mappings. To see the current rc parameters you can do print mpl.rcParams, or if you want to narrow it down a bit you can say print {k: v for k, v in mpl.rcParams.items() if "size" in k}

@mwaskom
Copy link
Owner

mwaskom commented Mar 4, 2014

I do take your point that the matplotlib documentation could be improved substantially, and it's something they're working on.

@sjobeek
Copy link
Author

sjobeek commented Mar 7, 2014

I think this might be somewhat related to #74 as well: As you mentioned, matplotlib has a lot of different ways of doing the same thing, which creates confusion.

I am 100% for a consistent, pythonic way of setting RC parameters, and I understand if this specific request doesn't yet fit with whatever future structure you may be planning for that.

@mwaskom
Copy link
Owner

mwaskom commented Mar 7, 2014

Yeah, I'm keeping this open for now as I will address it in some way in the branch that #74 is about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants