Skip to content

Commit 5a03445

Browse files
authored
Documentation Fixes (#17)
* bump version * docs * simplify style example
1 parent 1cbc7c3 commit 5a03445

File tree

8 files changed

+248
-195
lines changed

8 files changed

+248
-195
lines changed

docs/examples.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The created file should look something like this:
3535

3636
## Star Chart with an Extra Object Plotted
3737

38-
Building on the first example, you can also plot additional objects and even customize their style. Here's an example that plots the [Coma Star Cluster](https://en.wikipedia.org/wiki/Coma_Star_Cluster) (Mel 111) as a red star and also changes the plot style to `GRAYSCALE`:
38+
Building on the first example, you can also plot additional objects and even customize their style. Here's an example that plots the [Coma Star Cluster](https://en.wikipedia.org/wiki/Coma_Star_Cluster) (Melotte 111) as a red star and also changes the plot style to `GRAYSCALE`:
3939

4040
```python
4141
from datetime import datetime
@@ -44,7 +44,7 @@ import starplot as sp
4444

4545
tz = timezone("America/Los_Angeles")
4646

47-
p = splt.ZenithPlot(
47+
p = sp.ZenithPlot(
4848
lat=32.97,
4949
lon=-117.038611,
5050
dt=tz.localize(datetime.now().replace(hour=22)),
@@ -62,7 +62,7 @@ p.plot_object(
6262
},
6363
)
6464
)
65-
p.export("starchart-coma.png", format="png")
65+
p.export("starchart-coma.png")
6666

6767
```
6868

@@ -74,8 +74,6 @@ p.export("starchart-coma.png", format="png")
7474
The following code will create a simple map plot that shows the area around the constellation Orion, including an extra marker for M42 - The Great Orion Nebula:
7575

7676
```python
77-
from datetime import datetime
78-
from pytz import timezone
7977
import starplot as sp
8078

8179
style = sp.styles.MAP_BLUE.extend(
@@ -89,7 +87,7 @@ style = sp.styles.MAP_BLUE.extend(
8987
)
9088
style.star.label.font_size = 11
9189

92-
p = splt.MapPlot(
90+
p = sp.MapPlot(
9391
projection=Projection.MERCATOR,
9492
ra_min=3.6,
9593
ra_max=7.8,

docs/reference-styling.md

+111-168
Original file line numberDiff line numberDiff line change
@@ -50,174 +50,117 @@ style.bayer_labels.font_size = 10
5050

5151
## Creating a New PlotStyle
5252

53-
To create a whole new style, you can do it through code, JSON, or YAML:
54-
55-
=== "Python"
56-
57-
```python
58-
ps = PlotStyle(
59-
background_color = "#fff",
60-
text_border_width = 2,
61-
text_offset_x = 0.005,
62-
text_offset_y = 0.005,
63-
64-
# Borders
65-
border_font_size = 18,
66-
border_font_weight = FontWeightEnum.BOLD,
67-
border_font_color = "#000",
68-
border_line_color = "#000",
69-
border_bg_color = "#fff",
70-
71-
# Stars
72-
star = ObjectStyle(
73-
marker=MarkerStyle(fillstyle=FillStyleEnum.FULL),
74-
label=LabelStyle(font_size=9, font_weight=FontWeightEnum.BOLD, zorder=1024),
75-
),
76-
bayer_labels = LabelStyle(
77-
font_size=8, font_weight=FontWeightEnum.LIGHT, zorder=1024
78-
),
79-
80-
# Deep Sky Objects (DSOs)
81-
dso = ObjectStyle(
82-
marker=MarkerStyle(
83-
symbol=MarkerSymbolEnum.TRIANGLE, size=4, fillstyle=FillStyleEnum.FULL
84-
),
85-
label=LabelStyle(font_size=8),
86-
),
87-
88-
# Constellations
89-
constellation = PathStyle(
90-
line=LineStyle(color="#c8c8c8"),
91-
label=LabelStyle(font_size=7, font_weight=FontWeightEnum.LIGHT),
92-
),
93-
constellation_borders = LineStyle(
94-
color="#000", width=2, style=LineStyleEnum.DASHED, alpha=0.2, zorder=-100
95-
),
96-
97-
# Milky Way
98-
milky_way = PolygonStyle(
99-
color="#d9d9d9",
100-
alpha=0.36,
101-
edge_width=0,
102-
zorder=-10000,
103-
),
104-
)
105-
```
106-
107-
=== "JSON"
108-
109-
```json
110-
TODO
111-
```
112-
113-
=== "YAML"
114-
115-
```yaml
116-
# style.yml
117-
background_color: '#fff'
118-
bayer_labels:
119-
font_alpha: 1.0
120-
font_color: '#000'
121-
font_name: null
122-
font_size: 8
123-
font_style: normal
124-
font_weight: light
125-
visible: true
126-
zorder: 1024
127-
border_bg_color: '#fff'
128-
border_font_color: '#000'
129-
border_font_size: 18
130-
border_font_weight: bold
131-
border_line_color: '#000'
132-
constellation:
133-
label:
134-
font_alpha: 1.0
135-
font_color: '#000'
136-
font_name: null
137-
font_size: 7
138-
font_style: normal
139-
font_weight: light
140-
visible: true
141-
zorder: 1
142-
line:
143-
alpha: 1.0
144-
color: '#c8c8c8'
145-
style: solid
146-
width: 2
147-
zorder: -1
148-
constellation_borders:
149-
alpha: 0.2
150-
color: '#000'
151-
style: dashed
152-
width: 2
153-
zorder: -100
154-
dso:
155-
label:
156-
font_alpha: 1.0
157-
font_color: '#000'
158-
font_name: null
159-
font_size: 8
160-
font_style: normal
161-
font_weight: normal
162-
visible: true
163-
zorder: 1
164-
marker:
165-
alpha: 1.0
166-
color: '#000'
167-
fill: none
168-
size: 4
169-
symbol: ^
170-
visible: true
171-
zorder: -1
172-
milky_way:
173-
alpha: 0.36
174-
color: '#d9d9d9'
175-
edge_width: 0
176-
zorder: -10000
177-
star:
178-
label:
179-
font_alpha: 1.0
180-
font_color: '#000'
181-
font_name: null
182-
font_size: 9
183-
font_style: normal
184-
font_weight: bold
185-
visible: true
186-
zorder: 1024
187-
marker:
188-
alpha: 1.0
189-
color: '#000'
190-
fill: none
191-
size: 4
192-
symbol: .
193-
visible: true
194-
zorder: -1
195-
text_border_width: 2
196-
text_offset_x: 0.005
197-
text_offset_y: 0.005
198-
199-
```
200-
201-
**Using the above `style.yml`**:
202-
```python
203-
import starplot as splt
204-
205-
# load the style
206-
style = splt.styles.PlotStyle.load_from_file("style.yml")
207-
208-
p = splt.MapPlot(
209-
ra_min=3.6,
210-
ra_max=7.8,
211-
dec_min=-16,
212-
dec_max=23.6,
213-
style=style,
214-
)
215-
216-
```
217-
218-
!!! tip "Tip: Creating New Styles"
219-
220-
As you can see in the examples above, creating a whole new style from scratch is easiest to do via a YAML file. Doing it in code is certainly possible, but the result is very verbose.
53+
The easiest way to create a whole new style is by defining it in a YAML file, for example:
54+
55+
56+
```yaml
57+
# style.yml
58+
59+
background_color: '#fff'
60+
bayer_labels:
61+
font_alpha: 1.0
62+
font_color: '#000'
63+
font_name: null
64+
font_size: 7
65+
font_style: normal
66+
font_weight: light
67+
visible: true
68+
zorder: 1024
69+
border_bg_color: '#7997b9'
70+
border_font_color: '#f1f6ff'
71+
border_font_size: 18
72+
border_font_weight: bold
73+
border_line_color: '#2f4358'
74+
constellation:
75+
label:
76+
font_alpha: 1.0
77+
font_color: '#c5c5c5'
78+
font_name: null
79+
font_size: 11
80+
font_style: normal
81+
font_weight: light
82+
visible: true
83+
zorder: 1
84+
line:
85+
alpha: 0.34
86+
color: '#6ba832'
87+
style: solid
88+
visible: true
89+
width: 3
90+
zorder: -1
91+
constellation_borders:
92+
alpha: 0.2
93+
color: '#000'
94+
style: dashed
95+
visible: true
96+
width: 2
97+
zorder: -100
98+
dso:
99+
label:
100+
font_alpha: 1.0
101+
font_color: '#000'
102+
font_name: null
103+
font_size: 8
104+
font_style: normal
105+
font_weight: normal
106+
visible: true
107+
zorder: 1
108+
marker:
109+
alpha: 1.0
110+
color: '#000'
111+
fill: none
112+
size: 4
113+
symbol: ^
114+
visible: true
115+
zorder: -1
116+
milky_way:
117+
alpha: 0.16
118+
color: '#94c5e3'
119+
edge_width: 0
120+
visible: true
121+
zorder: -10000
122+
star:
123+
label:
124+
font_alpha: 1.0
125+
font_color: '#000'
126+
font_name: null
127+
font_size: 8
128+
font_style: normal
129+
font_weight: bold
130+
visible: true
131+
zorder: 1024
132+
marker:
133+
alpha: 1.0
134+
color: '#000'
135+
fill: none
136+
size: 4
137+
symbol: .
138+
visible: true
139+
zorder: -1
140+
text_border_width: 2
141+
text_offset_x: 0.005
142+
text_offset_y: 0.005
143+
144+
```
145+
146+
Then, to use your new style:
147+
148+
```python
149+
import starplot as sp
150+
151+
# load the style
152+
style = sp.styles.PlotStyle.load_from_file("style.yml")
153+
154+
p = sp.MapPlot(
155+
ra_min=3.6,
156+
ra_max=7.8,
157+
dec_min=-16,
158+
dec_max=23.6,
159+
style=style,
160+
)
161+
162+
```
163+
221164

222165
---
223166

0 commit comments

Comments
 (0)