Skip to content

Commit 0cd59a5

Browse files
committed
Merge branch 'master' of /home/tb/Downloads/PlotThemes-monorepo/PlotThemes.jl into monorepo-plotthemes
2 parents ed3e41b + f4ffe52 commit 0cd59a5

25 files changed

+901
-0
lines changed

PlotThemes/.github/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
documentation:
2+
- "**/*.md"
3+
enhancement:
4+
- "**/*.jl"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Run tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
julia-version: ['1.6', '1']
15+
julia-arch: [x64, x86]
16+
os: [ubuntu-latest, windows-latest, macOS-latest]
17+
exclude:
18+
- os: macOS-latest
19+
julia-arch: x86
20+
include:
21+
- version: 'nightly'
22+
os: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
- uses: julia-actions/setup-julia@v1
27+
with:
28+
version: ${{ matrix.julia-version }}
29+
arch: ${{ matrix.julia-arch }}
30+
- uses: julia-actions/julia-buildpkg@v1
31+
- uses: julia-actions/julia-runtest@v1
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CompatHelper
2+
on:
3+
schedule:
4+
- cron: 0 0 * * *
5+
workflow_dispatch:
6+
jobs:
7+
CompatHelper:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: "Add the General registry via Git"
11+
run: |
12+
import Pkg
13+
ENV["JULIA_PKG_SERVER"] = ""
14+
Pkg.Registry.add("General")
15+
shell: julia --color=yes {0}
16+
- name: "Install CompatHelper"
17+
run: |
18+
import Pkg
19+
name = "CompatHelper"
20+
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
21+
version = "3"
22+
Pkg.add(; name, uuid, version)
23+
shell: julia --color=yes {0}
24+
- name: "Run CompatHelper"
25+
run: |
26+
import CompatHelper
27+
CompatHelper.main()
28+
shell: julia --color=yes {0}
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: TagBot
2+
on:
3+
issue_comment:
4+
types:
5+
- created
6+
workflow_dispatch:
7+
jobs:
8+
TagBot:
9+
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: JuliaRegistries/TagBot@v1
13+
with:
14+
token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "Pull Request Labeler"
2+
on:
3+
- pull_request
4+
5+
jobs:
6+
triage:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/labeler@v2
10+
with:
11+
repo-token: "${{ secrets.GITHUB_TOKEN }}"

PlotThemes/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.jl.cov
2+
*.jl.*.cov
3+
*.jl.mem
4+
Manifest.toml
5+
/dev/

PlotThemes/LICENSE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The PlotThemes.jl package is licensed under the MIT "Expat" License:
2+
3+
> Copyright (c) 2016: Patrick Kofod Mogensen.
4+
>
5+
> Permission is hereby granted, free of charge, to any person obtaining a copy
6+
> of this software and associated documentation files (the "Software"), to deal
7+
> in the Software without restriction, including without limitation the rights
8+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
> copies of the Software, and to permit persons to whom the Software is
10+
> furnished to do so, subject to the following conditions:
11+
>
12+
> The above copyright notice and this permission notice shall be included in all
13+
> copies or substantial portions of the Software.
14+
>
15+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
> SOFTWARE.
22+
>

PlotThemes/Project.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name = "PlotThemes"
2+
uuid = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a"
3+
version = "3.3.0"
4+
5+
[deps]
6+
PlotUtils = "995b91a9-d308-5afd-9ec6-746e21dbc043"
7+
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
8+
9+
[compat]
10+
PlotUtils = "1"
11+
julia = "1"
12+
13+
[extras]
14+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
15+
16+
[targets]
17+
test = ["Test"]

PlotThemes/README.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# WARNING
2+
3+
https://github.com/JuliaPlots/PlotThemes.jl is now integrated into https://github.com/JuliaPlots/Plots.jl for Plots v2, please make corresponding PRs there.
4+
5+
# PlotThemes
6+
7+
[![Build Status](https://travis-ci.org/JuliaPlots/PlotThemes.jl.svg?branch=master)](https://travis-ci.org/JuliaPlots/PlotThemes.jl)
8+
9+
#### Primary author: Patrick Kofod Mogensen (@pkofod)
10+
11+
PlotThemes is a package to spice up the plots made with [Plots.jl](https://github.com/JuliaPlots/Plots.jl). To install:
12+
13+
```julia
14+
Pkg.add("PlotThemes")
15+
```
16+
17+
## Using PlotThemes
18+
19+
Currently the following themes are available:
20+
- `:default`
21+
- `:dark`
22+
- `:ggplot2`
23+
- `:juno`
24+
- `:lime`
25+
- `:orange`
26+
- `:sand`
27+
- `:solarized`
28+
- `:solarized_light`
29+
- `:wong`
30+
- `:wong2`
31+
- `:boxed`
32+
- `:gruvbox_dark`
33+
- `:gruvbox_light`
34+
- `:bright`
35+
- `:vibrant`
36+
- `:mute`
37+
- `:dao`
38+
- `:dracula`
39+
- `:rose_pine`
40+
- `:rose_pine_dawn`
41+
42+
43+
When using Plots, a theme can be set using the `theme` function:
44+
```julia
45+
using Plots
46+
theme(thm::Symbol; kwargs...)
47+
```
48+
`theme` accepts any Plots [attribute](https://docs.juliaplots.org/stable/attributes/) as keyword argument and sets its value as default for subsequent plots.
49+
50+
Themes can be previewed using `Plots.showtheme(thm::Symbol)`:
51+
52+
### `:default`
53+
![theme_default](https://user-images.githubusercontent.com/16589944/70847841-7ca7ea00-1e69-11ea-851e-e99d8559260d.png)
54+
55+
### `:dark`
56+
![theme_dark](https://user-images.githubusercontent.com/16589944/70847843-8d586000-1e69-11ea-9e39-5d4c44865750.png)
57+
58+
### `:ggplot2`
59+
![theme_ggplot2](https://user-images.githubusercontent.com/16589944/70847847-99442200-1e69-11ea-9ae8-ddd10ec4a303.png)
60+
61+
### `:juno`
62+
![theme_juno](https://user-images.githubusercontent.com/16589944/70847860-be389500-1e69-11ea-88b9-2a3bb3bbcf64.png)
63+
64+
### `:lime`
65+
![theme_lime](https://user-images.githubusercontent.com/16589944/70847863-c55fa300-1e69-11ea-8de7-3ef2a3a8ce30.png)
66+
67+
### `:orange`
68+
![theme_orange](https://user-images.githubusercontent.com/16589944/70847866-cf81a180-1e69-11ea-813a-7e4394311ef2.png)
69+
70+
### `:sand`
71+
![theme_sand](https://user-images.githubusercontent.com/16589944/70847868-d4deec00-1e69-11ea-8aab-de94af02bbfe.png)
72+
73+
### `:solarized`
74+
![theme_solarized](https://user-images.githubusercontent.com/16589944/70847869-dad4cd00-1e69-11ea-930e-b145e19bcff5.png)
75+
76+
### `:solarized_light`
77+
![theme_solarized_light](https://user-images.githubusercontent.com/16589944/70847872-df998100-1e69-11ea-955a-7fcc2e7043de.png)
78+
79+
### `:wong`
80+
![theme_wong](https://user-images.githubusercontent.com/16589944/70847875-e58f6200-1e69-11ea-904d-d4f7e27bb181.png)
81+
82+
### `:wong2`
83+
![theme_wong2](https://user-images.githubusercontent.com/16589944/70847880-eaecac80-1e69-11ea-9b59-cdf937427121.png)
84+
85+
### `:boxed`
86+
![theme_boxed](https://github.com/user-attachments/assets/ed1baaf1-4679-4d9a-9667-3118dc42200e)
87+
88+
### `:gruvbox_dark`
89+
![theme_gruvbox_dark](https://user-images.githubusercontent.com/16589944/70847882-f049f700-1e69-11ea-94f8-255f2cd17288.png)
90+
91+
### `:gruvbox_light`
92+
![theme_gruvbox_light](https://user-images.githubusercontent.com/16589944/70847885-fb048c00-1e69-11ea-9546-4dc0d9e4154c.png)
93+
94+
### `:bright`
95+
![theme_bright](https://user-images.githubusercontent.com/16589944/70848065-8ed75780-1e6c-11ea-8e59-9882b3c4a4db.png)
96+
97+
### `:vibrant`
98+
![theme_vibrant](https://user-images.githubusercontent.com/16589944/70848066-926ade80-1e6c-11ea-91ba-fd08d14e6963.png)
99+
100+
### `:mute`
101+
![theme_mute](https://user-images.githubusercontent.com/16589944/70848069-9860bf80-1e6c-11ea-9cac-8a797d526835.png)
102+
103+
### `:dao`
104+
![theme_dao](https://user-images.githubusercontent.com/7330605/106512313-54de7000-64c9-11eb-98d5-2aee3603879a.png)
105+
106+
### `:dracula`
107+
![theme_dracula](https://user-images.githubusercontent.com/64332767/136754217-31d4348a-c873-4496-8b66-905e4d8a7e36.png)
108+
109+
### `:rose_pine`
110+
![theme_rose_pine](https://github.com/BaerLKR/PlotThemes.jl/assets/83340886/30c869e5-2b90-405a-bc49-cf4ef3c43d75)
111+
112+
### `:rose_pine_dawn`
113+
![theme_rose_pine_dawn](https://github.com/BaerLKR/PlotThemes.jl/assets/83340886/e30c0b46-1be3-49f5-afc5-ceede0b0c27d)
114+
115+
## Contributing
116+
A theme specifies default values for different Plots [attributes](https://docs.juliaplots.org/stable/attributes/).
117+
At the moment these are typically colors, palettes and colorgradients, but any Plots attribute can be controlled by a theme in general.
118+
PRs for new themes very welcome! Adding a new theme (e.g. `mytheme`) is as easy as adding a new file (mytheme.jl) that contains at least the following line:
119+
```julia
120+
_themes[:mytheme] = PlotTheme(; kwargs...)
121+
```
122+
The keyword arguments can be any collection of Plots attributes plus a colorgradient keyword argument.
123+
For adding the `showtheme` figure to `README.md`, use
124+
```julia
125+
Plots.showtheme(:your_theme)
126+
plot!(dpi=400)
127+
savefig("your_theme.png")
128+
```
129+
The image can be uploaded to the `README.md` file by pulling it in with the file-editing web interface.

PlotThemes/src/PlotThemes.jl

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
module PlotThemes
2+
3+
using PlotUtils
4+
5+
export add_theme, theme_palette, PlotTheme
6+
7+
_255_to_1(c::Symbol, colors) = RGBA(map(x-> x/255,colors[c])...)
8+
RGB255(r,g,b) = RGB(r/255, g/255, b/255)
9+
10+
function expand_palette(bg, cs; kwargs...)
11+
colors = palette(cs).colors.colors
12+
c = convert.(RGBA, distinguishable_colors(20, vcat(bg, colors); kwargs...))[2:end]
13+
return palette(c)
14+
end
15+
16+
const KW = Dict{Symbol, Any}
17+
18+
struct PlotTheme
19+
defaults::KW
20+
end
21+
22+
PlotTheme(; kw...) = PlotTheme(KW(kw))
23+
24+
# adjust an existing theme
25+
PlotTheme(base::PlotTheme; kw...) = PlotTheme(KW(base.defaults..., KW(kw)...))
26+
27+
"Get the palette of a PlotTheme"
28+
function theme_palette(s::Symbol)
29+
if haskey(_themes, s) && haskey(_themes[s].defaults, :palette)
30+
return _themes[s].defaults[:palette]
31+
else
32+
return palette(:default)
33+
end
34+
end
35+
36+
37+
# add themes
38+
include("dark.jl")
39+
include("ggplot2.jl")
40+
include("solarized.jl")
41+
include("sand.jl")
42+
include("lime.jl")
43+
include("orange.jl")
44+
include("wong.jl")
45+
include("boxed.jl")
46+
include("juno.jl")
47+
include("gruvbox.jl")
48+
include("sheet.jl")
49+
include("dao.jl")
50+
include("dracula.jl")
51+
include("rose_pine.jl")
52+
53+
54+
const _themes = Dict{Symbol, PlotTheme}([
55+
:default => PlotTheme(),
56+
:dao => _dao,
57+
:dark => _dark,
58+
:ggplot2 => _ggplot2,
59+
:gruvbox_light => _gruvbox_light,
60+
:gruvbox_dark => _gruvbox_dark,
61+
:solarized => _solarized,
62+
:solarized_light => _solarized_light,
63+
:sand => _sand,
64+
:bright => _bright,
65+
:vibrant => _vibrant,
66+
:mute => _mute,
67+
:wong => _wong,
68+
:wong2 => _wong2,
69+
:boxed => _boxed,
70+
:juno => _juno,
71+
:lime => _lime,
72+
:orange => _orange,
73+
:dracula => _dracula,
74+
:rose_pine => _rose_pine,
75+
:rose_pine_dawn => _rose_pine_dawn
76+
77+
])
78+
79+
80+
function add_theme(s::Symbol, thm::PlotTheme)
81+
_themes[s] = thm
82+
end
83+
84+
85+
end # module

0 commit comments

Comments
 (0)