Closed codingfar closed 5 months ago
Hi, thanks for reporting these issues! It seems the documentation is not very clear that some objects have a PathStyle
, some have a LineStyle
, and some have a wrapper that includes something like a LineStyle
AND a LabelStyle
— I implemented it this way to keep the styling flexible. I’ll try to make this more clear in the documentation.
Anyway, I updated your code and added a few comments to get your first example working:
from starplot import PlotStyle, MapPlot, Projection
style = PlotStyle()
style.bayer_labels.font_name = "Times New Roman"
style.bayer_labels.font_size = 15
# since the constellation borders are a LineStyle, you can set the alpha directly.
# Currently they have no labels, so I didn't wrap the border style in a PathStyle
# like the Celestial Equator (which DOES have an optional label)
style.constellation_borders.alpha = 0
style.milky_way.alpha = 0
# Gridlines have labels on the plot axes, so gridlines are actually a PathStyle
# (which has a "line" and a "label"). So, to set ONLY the alpha on the lines, use:
style.gridlines.line.alpha = 0
# for the labels you'd do:
# style.gridlines.label.font_alpha = 0
# below code is unchanged:
p = MapPlot(
projection=Projection.MERCATOR,
ra_min=4.6,
ra_max=6.4,
dec_min=-16,
dec_max=23.6,
limiting_magnitude=6.0,
style=style,
resolution=3600,
)
p.export("test.png", padding=0.5)
With those changes, I get this:
Also, if you want to hide certain objects, I recommend setting the visible
style property to "false" instead of alpha
to 0 because Starplot will exit functions early (and thus, speed up total run time) when an object's visibility is set to false.
In your second example that loads a style from a YAML file, looks like this is caused by a bug in the PlotStyle’s load_from_file
function. I just released a new version of Starplot, 0.7.1, that fixes this :)
With the bug fix, I get this when running your code:
Which looks correct, except the star symbols are dots instead of stars. I’ll look into that…
Thanks again for reporting these issues! Starplot is still very much a work in progress, so I also appreciate your patience and understanding.
I figured out why the star symbols are being plotted as dots instead of what's in the style, so I'll fix that bug soon too. I'll keep this issue open until then.
Using the code
style.constellation_borders.alpha = 0
or, for example,style.bayer_labels.font_size = 15
works just fine, but inserting the codestyle.gridlines.alpha = 0
returns: ValueError: "PathStyle" object has no field "alpha". The same occurs if one tries, say,style.celestial_equator.alpha = 0
. The code I was trying to use is copied below.Alternatively, trying to create a style using a YAML file did not work. I tried the following code (adapted from the "More Complex Example" on the website):
I used the following YAML file:
However, although this did not return any errors, none of the chosen style options were implemented in the chart that was produced.