Skip to content

Commit

Permalink
round labels to 3 significant digits
Browse files Browse the repository at this point in the history
  • Loading branch information
artiom-matvei committed Oct 28, 2024
1 parent 01e4c89 commit e291fc7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions marginaleffects/plot_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def dt_on_condition(model, condition):


def condition_numeric(modeldata, key, value, first):
# upgrade this to use match-case when python 3.9 reaches end-of-life
if value is None:
if first:
out = np.linspace(modeldata[key].min(), modeldata[key].max(), 100).tolist()
Expand Down Expand Up @@ -97,6 +98,7 @@ def plot_labels(model, dt, condition):

for k, v in condition.items():
if model.variables_type[k] in ["numeric", "integer"]:
# upgrade this to use match-case when python 3.9 reaches end-of-life
if condition[k] == "threenum":
lab = ["-SD", "Mean", "+SD"]
dt = ordered_cat(dt, k, lab)
Expand All @@ -106,6 +108,8 @@ def plot_labels(model, dt, condition):
elif condition[k] == "minmax":
lab = ["Min", "Max"]
dt = ordered_cat(dt, k, lab)
elif condition[k] is None:
dt = dt.with_columns(pl.col(k).round_sig_figs(3).alias(k))
return dt


Expand Down
Binary file modified tests/images/plot_slopes/issue114_slopes_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/plot_slopes/issue114_slopes_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/plot_slopes/issue114_slopes_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e291fc7

Please sign in to comment.