Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate setvars setting of plotvars attributes #50

Open
sadielbartholomew opened this issue Apr 10, 2024 · 0 comments
Open

Consolidate setvars setting of plotvars attributes #50

sadielbartholomew opened this issue Apr 10, 2024 · 0 comments
Assignees

Comments

@sadielbartholomew
Copy link
Member

Similarly to #49, but more specifically, there is a long code block of logically-similar conditional setting which can and should be reduced down to three or so lines using setattr(), since the statements all have the same structure:

cf-plot/cfplot/cfplot.py

Lines 8275 to 8381 in efe94c7

if file is not None:
plotvars.file = file
# TODO SLB consolidate this long list of conditional setting!
if title_fontsize is not None:
plotvars.title_fontsize = title_fontsize
if axis_label_fontsize is not None:
plotvars.axis_label_fontsize = axis_label_fontsize
if continent_thickness is not None:
plotvars.continent_thickness = continent_thickness
if continent_color is not None:
plotvars.continent_color = continent_color
if continent_linestyle is not None:
plotvars.continent_linestyle = continent_linestyle
if text_fontsize is not None:
plotvars.text_fontsize = colorbar_fontsize
if colorbar_fontsize is not None:
plotvars.colorbar_fontsize = colorbar_fontsize
if text_fontweight is not None:
plotvars.text_fontweight = text_fontweight
if axis_label_fontweight is not None:
plotvars.axis_label_fontweight = axis_label_fontweight
if colorbar_fontweight is not None:
plotvars.colorbar_fontweight = colorbar_fontweight
if title_fontweight is not None:
plotvars.title_fontweight = title_fontweight
if viewer is not None:
plotvars.viewer = viewer
if tspace_year is not None:
plotvars.tspace_year = tspace_year
if tspace_month is not None:
plotvars.tspace_month = tspace_month
if tspace_day is not None:
plotvars.tspace_day = tspace_day
if tspace_hour is not None:
plotvars.tspace_hour = tspace_hour
if xtick_label_rotation is not None:
plotvars.xtick_label_rotation = xtick_label_rotation
if xtick_label_align is not None:
plotvars.xtick_label_align = xtick_label_align
if ytick_label_rotation is not None:
plotvars.ytick_label_rotation = ytick_label_rotation
if ytick_label_align is not None:
plotvars.ytick_label_align = ytick_label_align
if legend_text_size is not None:
plotvars.legend_text_size = legend_text_size
if legend_text_weight is not None:
plotvars.legend_text_weight = legend_text_weight
if cs_uniform is not None:
plotvars.cs_uniform = cs_uniform
if master_title is not None:
plotvars.master_title = master_title
if master_title_location is not None:
plotvars.master_title_location = master_title_location
if master_title_fontsize is not None:
plotvars.master_title_fontsize = master_title_fontsize
if master_title_fontweight is not None:
plotvars.master_title_fontweight = master_title_fontweight
if dpi is not None:
plotvars.dpi = dpi
if land_color is not None:
plotvars.land_color = land_color
if ocean_color is not None:
plotvars.ocean_color = ocean_color
if lake_color is not None:
plotvars.lake_color = lake_color
if feature_zorder is not None:
plotvars.feature_zorder = 999
if rotated_grid_spacing is not None:
plotvars.rotated_grid_spacing = rotated_grid_spacing
if rotated_deg_spacing is not None:
plotvars.rotated_deg_spacing = rotated_deg_spacing
if rotated_grid_thickness is not None:
plotvars.rotated_grid_thickness = rotated_grid_thickness
if rotated_continents is not None:
plotvars.rotated_continents = rotated_continents
if rotated_grid is not None:
plotvars.rotated_grid = rotated_grid
if rotated_labels is not None:
plotvars.rotated_labels = rotated_labels
if legend_frame is not None:
plotvars.legend_frame = legend_frame
if legend_frame_edge_color is not None:
plotvars.legend_frame_edge_color = legend_frame_edge_color
if legend_frame_face_color is not None:
plotvars.legend_frame_face_color = legend_frame_face_color
if degsym is not None:
plotvars.degsym = degsym
if axis_width is not None:
plotvars.axis_width = axis_width
if grid is not None:
plotvars.grid = grid
if grid_x_spacing is not None:
plotvars.grid_x_spacing = grid_x_spacing
if grid_y_spacing is not None:
plotvars.grid_y_spacing = grid_y_spacing
if grid_colour is not None:
plotvars.grid_colour = grid_colour
if grid_linestyle is not None:
plotvars.grid_linestyle = grid_linestyle
if grid_thickness is not None:
plotvars.grid_thickness = grid_thickness
if grid_zorder is not None:
plotvars.grid_zorder = grid_zorder
if tight is not None:
plotvars.tight = tight
if level_spacing is not None:
plotvars.level_spacing = level_spacing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant