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

Improve colour support #4

Merged
merged 53 commits into from
Oct 25, 2023
Merged

Improve colour support #4

merged 53 commits into from
Oct 25, 2023

Conversation

davep
Copy link
Contributor

@davep davep commented Oct 23, 2023

Motivated by Textualize/textual#3532 and #3, this PR aims to sets better default theme choices for the PlotextPlot widget, as well as adding a parallel set of themes that are the same as the Plotext-supplied, but which have all the colours transformed into RGB values, helping to ensure plots stay looking the same across various terminals and various terminal themes (on terminals that support themes).

It also adds two (currently quite simplistic) "textual design" themes; one for dark mode and one for light mode. These are set as the default dark and light themes used by the PlotextPlot widget when auto_theme is True.

This all means that the weather example, which used to look like this with the "out of the box" colour:

textual-plotext-example-1

now looks like this:

Screenshot 2023-10-24 at 14 27 57

The main differences here being that the default theme now lets the background colour be the canvas and axes colour, and that the ticks colour (in other words the foreground of the axes) is a suitable version of $accent.

Also added is a new example application which can be used to explore the themes provided by Plotext and this library.

Screenshot 2023-10-24 at 14 19 51

Still deciding: if the textual-design themes should have hand-picked data colours (right now it's just using the default ones, made RGB).

davep added 3 commits October 23, 2023 10:20
See #3 and Textualize/textual#3532 for some
background. Some Plotext themes use ANSI colours and "hard code" things;
others blend a lot better with Textual. In further testing it seems that out
of the box "clear" and "pro" are a better fit within Textual *and* they work
well with light/dark mode.

So while not the most colourful of themes, they are the most pleasing to the
eye as a default experience. Because of this, let's make Pro the default in
both cases.
@davep davep added the enhancement New feature or request label Oct 23, 2023
@davep davep linked an issue Oct 23, 2023 that may be closed by this pull request
davep added 25 commits October 23, 2023 13:45
Rather than dumpster-dive the internals of Plotext.
Initially testing with a version of the default theme.
Instead, by default, use a theme that is far more textual-friendly and which
is responsive to light and dark mode to start with.

This means Textualize/textual#3532 is less of an
issue right out of the gate as the default theme will blend in way better.
Also make textual-clear the same as Plotext's clear, in that it's all
no-color. Because of this, switch the default theme for the widget to
textual-default.
This should (and appears to) make things look more like you'd expect as a
Plotext user, while making it look the same everywhere.
Rather than hand-patch each of the themes, I think it'll make more sense to
just patch the odd one that really needs it, and then automate the patching
of the rest.
This is what you get for copy/paste.
davep added 16 commits October 24, 2023 08:38
And, in doing so, make them the default auto-theme themes, and turn
auto-theme back on by default.

Overall this isn't really going to make much of a difference to how a plot
looks out of the box; but it does mean we can tweak things a little as time
goes on. It also means that if we change anything in the Textual design,
this should follow.

Right now, initially, it simply uses $accent for the ticks and leaves the
background as the default.
mypy doesn't like it if you try and loop over a query, despite the fact that
it works; I'm pretty sure pyright used to complain about this but it seems
fine with it these days. No matter, let's keep everyone happy.
I think we may want to dial in the colour sequence (in other words the
colours to use for subsequent plots of data) for some of the themes --
especially the textual-design-* themes -- so it will make life easier if
there's a mode where you can clearly see what colours are used where.

This should be it. It's like a test card mode.
@davep
Copy link
Contributor Author

davep commented Oct 24, 2023

Current state of the theme explorer.

Screen.Recording.2023-10-24.at.15.24.09.mov

davep added 9 commits October 24, 2023 17:41
This is still up for tweaking, but I feel this is narrowing it down to a
pleasing palette of colours that work for dark and light mode, and for up to
20 plots in a single plot.

I've kept almost all of the plotext-derived themes using their own sets, as
I believe that's what people will be expecting, but for a couple (default
and pro) I go with this curated set this seems like it'll likely be what
people will use out of the box (actually I suspect most people will simply
go with the textual-design-* themes).

This might get a bit more tweaking; but I think this is close and sets the
stage.
@davep davep changed the title WiP: Improve colour support Improve colour support Oct 25, 2023
@davep davep marked this pull request as ready for review October 25, 2023 10:37
@davep davep merged commit be2d422 into main Oct 25, 2023
@davep davep deleted the improve-colour-support branch October 25, 2023 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate more Textual-friendly colouring and theming
1 participant