Skip to content

Commit d23b1b9

Browse files
authored
Style refactor (#25)
* updating docs * clean up * update examples * style extensions in yml * dark style example * fix some styles * comment * automate example code in docs * clean up examples * style fixes * readme
1 parent 75d5200 commit d23b1b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+803
-192578
lines changed

README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
-**Zenith Plots** - showing the stars from a specific time/location
99
- 🗺️ **Map Plots** - including North/South polar and Mercator projections
10+
- 🪐 **Planets and Deep Sky Objects (DSOs)**
1011
- 🎨 **Custom Styles** - for all objects
1112
- 📥 **Export** - png, svg
1213
- 🧭 **Label Collision Avoidance**
@@ -16,7 +17,7 @@
1617
![starchart-blue](https://github.com/steveberardi/starplot/blob/main/examples/01_star_chart.png?raw=true)
1718

1819
*Map around the constellation Orion, with M42 marked:*
19-
![map-orion](https://github.com/steveberardi/starplot/blob/main/examples/03_map_orion.svg?raw=true)
20+
![map-orion](https://github.com/steveberardi/starplot/blob/main/examples/03_map_orion.png?raw=true)
2021

2122

2223
## Basic Usage
@@ -28,12 +29,13 @@ from datetime import datetime
2829
from pytz import timezone
2930
import starplot as sp
3031

32+
tz = timezone("America/Los_Angeles")
33+
3134
p = sp.ZenithPlot(
3235
lat=33.363484,
3336
lon=-116.836394,
34-
dt=timezone("America/Los_Angeles").localize(datetime.now().replace(hour=22)),
37+
dt=datetime.now(tz).replace(hour=22),
3538
limiting_magnitude=4.6,
36-
style=sp.styles.ZENITH_BLUE_MEDIUM,
3739
resolution=2000,
3840
)
3941
p.export("starchart.png")
@@ -57,6 +59,9 @@ p.export("starchart.png")
5759

5860
## Coming Soon
5961

62+
- ⭐ Tycho stars
63+
- 🌖 Moon
64+
- 📋 Map legends
6065
- 🔭 Scope plots - that will simulate what you'll see through a telescope eyepiece
6166
- ⚖️ Better auto font-size adjustment
6267
- ☄️ Better label collision detection and handling

docs/css/extra.css

+11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
}
4141

4242

43+
.indent {
44+
margin-left: 1rem;
45+
padding-left: 1rem;
46+
border-left: 1px solid rgb(201, 201, 201);
47+
}
48+
4349
.doc-contents.first {
4450
/* border-top: 2px solid rgba(200, 200, 200, 0.6);
4551
margin-left: 1rem;
@@ -74,4 +80,9 @@
7480
.doc-object .doc-attribute .doc-contents {
7581
margin-bottom: 0;
7682
padding-bottom: 1rem;
83+
}
84+
85+
code.raw {
86+
display: block;
87+
white-space: pre-wrap
7788
}

docs/examples.md

+15-98
Original file line numberDiff line numberDiff line change
@@ -4,126 +4,43 @@ This page has a few examples to get you familiar with Starplot and how it works.
44
2. [Star Chart with an Extra Object Plotted](#star-chart-with-an-extra-object-plotted)
55
3. [Map of Orion](#map-of-orion)
66

7+
8+
79
## Star Chart for Time/Location
8-
To create a star chart for tonight's sky as seen from [Palomar Mountain](https://en.wikipedia.org/wiki/Palomar_Mountain) in California:
10+
To create a star chart for the sky as seen from [Palomar Mountain](https://en.wikipedia.org/wiki/Palomar_Mountain) in California on July 13, 2023 at 10pm PT:
911

1012
```python
11-
from datetime import datetime
12-
from pytz import timezone
13-
import starplot as sp
14-
15-
tz = timezone("America/Los_Angeles")
16-
17-
p = sp.ZenithPlot(
18-
lat=33.363484,
19-
lon=-116.836394,
20-
dt=tz.localize(datetime.now().replace(hour=22)),
21-
limiting_magnitude=4.6,
22-
style=sp.styles.ZENITH_BLUE_MEDIUM,
23-
resolution=2000,
24-
)
25-
p.export("01_star_chart.png")
13+
{% include 'examples/example_1.py' %}
2614
```
27-
The created file should look something like this:
2815

29-
![starchart-blue](images/starchart-blue.png)
30-
31-
!!! info "Does your result look different?"
16+
The created file should look something like this:
3217

33-
Your result may look a little different depending on the date/time you run this code (because the position of the stars in the sky depends on time/location). But, the example above reflects what the chart would like for a day in July.
18+
![starchart-blue](images/example_1.png)
3419

3520

3621
## Star Chart with an Extra Object Plotted
3722

3823
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`:
3924

4025
```python
41-
from datetime import datetime
42-
from pytz import timezone
43-
import starplot as sp
44-
45-
tz = timezone("America/Los_Angeles")
46-
47-
p = sp.ZenithPlot(
48-
lat=32.97,
49-
lon=-117.038611,
50-
dt=tz.localize(datetime.now().replace(hour=22)),
51-
limiting_magnitude=4.6,
52-
style=sp.styles.ZENITH_GRAYSCALE,
53-
resolution=2000,
54-
)
55-
p.plot_object(
56-
sp.SkyObject(
57-
name="Mel 111",
58-
ra=12.36,
59-
dec=25.85,
60-
style={
61-
"marker": {"size": 10, "symbol": "*", "fill": "full", "color": "red"}
62-
},
63-
)
64-
)
65-
p.export("02_star_chart_extra.png")
66-
26+
{% include 'examples/example_2.py' %}
6727
```
6828

69-
![zenith-coma](images/zenith-coma.png)
29+
![zenith-coma](images/example_2.png)
7030

7131

7232
## Map of Orion
7333

7434
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:
7535

7636
```python
77-
import starplot as sp
78-
79-
style = sp.styles.MAP_BLUE_LIGHT.extend(
80-
{
81-
"bayer_labels": {
82-
"font_name": "GFS Didot", # use a better font for Greek letters
83-
"font_size": 7,
84-
"font_alpha": 0.9,
85-
},
86-
}
87-
)
88-
style.star.label.font_size = 11
89-
90-
p = sp.MapPlot(
91-
projection=sp.Projection.MERCATOR,
92-
ra_min=3.6,
93-
ra_max=7.8,
94-
dec_min=-16,
95-
dec_max=23.6,
96-
limiting_magnitude=7.2,
97-
style=style,
98-
resolution=4000,
99-
)
100-
p.plot_object(
101-
sp.SkyObject(
102-
name="M42",
103-
ra=5.58333,
104-
dec=-4.61,
105-
style={
106-
"marker": {
107-
"size": 10,
108-
"symbol": "s",
109-
"fill": "full",
110-
"color": "#ff6868",
111-
"alpha": 1,
112-
"zorder": 4096,
113-
},
114-
"label": {
115-
"font_size": 10,
116-
"font_weight": "bold",
117-
"font_color": "darkred",
118-
"zorder": 4096,
119-
},
120-
},
121-
)
122-
)
123-
p.export("03_map_orion.svg", format="svg", padding=0.5)
124-
125-
37+
{% include 'examples/example_3.py' %}
12638
```
39+
12740
The result should look something like this:
12841

129-
![map-orion](images/03_map_orion.svg)
42+
![map-orion](images/example_3.png)
43+
44+
---
45+
46+
*Check out the code reference to learn more about using starplot!*

0 commit comments

Comments
 (0)