apmtools 0.2.6__tar.gz → 0.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: apmtools
3
- Version: 0.2.006
3
+ Version: 0.2.007
4
4
  Summary: A collection of tools for processing air pollution monitoring data
5
5
  Project-URL: Homepage, https://github.com/federlorenz/apmtools
6
6
  Author-email: Federico Lorenzetti <lorenzetti.federico@gmail.com>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "apmtools"
7
- version = "0.2.006"
7
+ version = "0.2.007"
8
8
  authors = [
9
9
  { name="Federico Lorenzetti", email="lorenzetti.federico@gmail.com" },
10
10
  ]
@@ -351,12 +351,43 @@ def create_summary_app(
351
351
  )
352
352
 
353
353
  if selected_plot == "histogram":
354
- long_df = plot_df[y_columns].melt(
355
- var_name="variable", value_name="value")
356
- fig = px.histogram(
357
- long_df, x="value", color="variable", nbins=int(input.bins()),
358
- barmode="overlay" if len(y_columns) > 1 else "relative",
359
- )
354
+ if group_columns:
355
+ # With grouping, overlay one histogram per group on the
356
+ # same axes. ``group`` is the color dimension rather
357
+ # than the selected variable, so each group gets its own
358
+ # histogram. Transparency makes overlapping groups
359
+ # directly comparable.
360
+ group_column = "__plot_group"
361
+ long_df = plot_df[[group_column, *y_columns]].melt(
362
+ id_vars=[group_column],
363
+ var_name="variable",
364
+ value_name="value",
365
+ )
366
+ fig = px.histogram(
367
+ long_df,
368
+ x="value",
369
+ color=group_column,
370
+ nbins=int(input.bins()),
371
+ barmode="overlay",
372
+ opacity=0.45,
373
+ facet_row=("variable" if len(y_columns) > 1 else None),
374
+ )
375
+ # Keep the groups as the legend entries rather than the
376
+ # selected Y variables.
377
+ fig.update_traces(marker_line_width=0)
378
+ else:
379
+ long_df = plot_df[y_columns].melt(
380
+ var_name="variable", value_name="value"
381
+ )
382
+ fig = px.histogram(
383
+ long_df,
384
+ x="value",
385
+ color="variable",
386
+ nbins=int(input.bins()),
387
+ barmode="overlay" if len(
388
+ y_columns) > 1 else "relative",
389
+ opacity=0.65 if len(y_columns) > 1 else 1.0,
390
+ )
360
391
  elif selected_plot == "box":
361
392
  if not group_columns:
362
393
  long_df = plot_df[y_columns].melt(
File without changes
File without changes
File without changes
File without changes