Skip to content

Commit

Permalink
Merge pull request #78 from NCAR/min_ticks
Browse files Browse the repository at this point in the history
Customize minor ticks NCL_plot
  • Loading branch information
pilotchute committed Aug 15, 2022
2 parents 9a4e27a + bca92ec commit fe9ab2f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/geocat/viz/plot_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class NCL_Plot(ABC):
mappable: :class:`cartopy.mpl.contour.GeoContourSet`
The matplotlib.cm.ScalarMappable object that the colorbar represents. Mandatory when first creating colorbar, but not for subsequent calls.
minor_per_major: obj:`list`
Number of minor ticks per major tick [x-axis, y-axis]. Default [3, 3] unless type="press_height", then default is [3, 1].
overlay: :class:`contourf.Contour`
Reference figure that the object will be created based on. For example, when overlaying plots or creating subplots, the overlay would be the name of the first plot.
Expand Down Expand Up @@ -264,9 +267,9 @@ def _setup_args_kwargs(self, class_specific_kwargs_set: set,
'individual_cb', 'label_font_size', 'lakes_on', 'land_on',
'left_title', 'left_title_fontsize', 'line_color', 'line_style',
'line_width', 'main_title', 'main_title_fontsize', 'mappable',
"overlay", 'projection', 'raxis', 'raxis_label', 'raxis_scale',
'raxis_tick_label_fontsize', 'raxis_ticks', 'right_title',
'right_title_fontsize', "set_extent", "subplot",
'minor_per_major', "overlay", 'projection', 'raxis', 'raxis_label',
'raxis_scale', 'raxis_tick_label_fontsize', 'raxis_ticks',
'right_title', 'right_title_fontsize', "set_extent", "subplot",
'tick_label_fontsize', 'type', 'w', 'X', 'xlabel', 'xlim', "xscale",
'xticks', 'xtick_labels', 'Y', 'ylabel', 'ylim', "yscale", 'yticks',
'ytick_labels'
Expand All @@ -277,6 +280,7 @@ def _setup_args_kwargs(self, class_specific_kwargs_set: set,
'cmap': 'plasma',
'line_color': "black",
'line_width': 0.4,
'minor_per_major': [3, 3],
'w': 8,
'h': 8,
'cb_orientation': "horizontal",
Expand Down Expand Up @@ -509,7 +513,14 @@ def _set_NCL_style(self,
if self.tick_label_fontsize is None:
self.tick_label_fontsize = tick_label_fontsize

add_major_minor_ticks(ax, labelsize=str(self.tick_label_fontsize))
# if pressure height, don't add minor ticks to y-axis
if self.type == 'press_height':
self.minor_per_major[1] = 1

add_major_minor_ticks(ax,
labelsize=str(self.tick_label_fontsize),
x_minor_per_major=self.minor_per_major[0],
y_minor_per_major=self.minor_per_major[1])

# if pressure height, remove right hand ticks on original axis
if self.type == "press_height":
Expand Down

0 comments on commit fe9ab2f

Please sign in to comment.