mwshinn / CanD

6 stars 3 forks source link

Add titlesize setting #6

Closed syncrostone closed 3 years ago

syncrostone commented 3 years ago

I added a setting to set_font that allows setting a different titlesize from the general size.

mwshinn commented 3 years ago

Thanks for the PR! I'll merge this for now, but know that I'm planning on changing how this works. In theory, the same thing could be applied to axis labels as well. Additionally, people might want to change other font details for these (e.g. bold, different typeface, etc.) So it starts to turn into whack-a-mole for individual use cases. Instead, there will be one function which takes the optional arguments of add_text as well as a type of text (tick label, axis label, title ,etc.) and sets the font for those alone.

syncrostone commented 3 years ago

That makes sense as an option, but would that allow people to use the default axes / title labels e.g. from seaborn with their preferred font details? Or would they have to remove those labels manually and then re-add them via the add_text method?

If they pass preferred font size to a plotting function like in seaborn, would those be overwritten by CanD?

I have previously preferred using matplotlib ax.set_title and ax.set_ylabel functions to the add_text method because I find the positioning good and convenient, and the matplotlib functions require less effort than using add_text with the correct axis frame and positioning.

mwshinn commented 3 years ago

What about something like c.title(axis_name, "Title goes here", font_props) where ... are arguments to set_text?

Or alternatively, c.set("title", axis_name, "Title goes here", font_props)?

Yes, CanD will overwrite any font properties passed to seaborn. Since CanD support is not implemented in seaborn, CanD needs to overwrite their font specifications.

CanD tries to optimize for fine control and consistency (of both the API and the eventual figure), and encouraging people to use set_title, etc. runs against those goals since (a) it is a separate system for adding text, and (b) it doesn't allow normal font properties.

The other option is for CanD to monkeypatch the set_title, etc. methods, but this will get messy really quickly and is probably the least preferred option.

syncrostone commented 3 years ago

c.set_title, c.set_ylabel, c.set_xlabel, c.set_xticks, c.set_yticks in that format could be good like that, yes. (or c.set("title...) c.set("ylabel"...) etc. When using matplotlib, this is very similar to what I already do, so it would not change my workflow or figure code very much.

I still really like the user side elegance of setting presets in canvas (e.g. tick size, title size, etc) and it would be able to pass font_props as an object in this case so e.g. if I have a couple different default font settings with combinations of sizes, font, style, etc I can pass in my style rather than each individual setting. [I realized after typing this that this is what I think you mean by "type of text" in your first comment]

c.set etc. however does not fix the issue when using seaborn plots from pandas dataframes which nicely create axis labels and legends for you. I do still think it is nice to retain the ability to overwrite those with defaults in canvas rather than having to remove and re-add. I know there will be less granularity that way then with c.set / c.add_text, but I still think it is a useful feature to have if one uses seaborn figures. I'm not currently using seaborn figures with Canvas though so maybe this is a non-issue.