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

Dual-scale charts (bad idea)? #147

Open
mbostock opened this issue Feb 24, 2021 · 16 comments
Open

Dual-scale charts (bad idea)? #147

mbostock opened this issue Feb 24, 2021 · 16 comments
Labels
enhancement New feature or request

Comments

@mbostock
Copy link
Member

mbostock commented Feb 24, 2021

Ref. https://blog.datawrapper.de/dualaxis/

@mbostock mbostock added the enhancement New feature or request label Feb 24, 2021
@Fil
Copy link
Contributor

Fil commented Dec 22, 2021

Discussion: #626

Examples: https://observablehq.com/@fil/dual-axis-bar-line-chart

@papakpmartin
Copy link

Just a quick note that while I do understand that dual scale charts can be badly used, I frequently find myself wishing for them. Eespecially when I'm looking at runtime data from a system that I've sensored up; even though "flow" and "conductivity" might have totally different scales, how they relate to each other at each moment is the thing I want to see.

Doing that side by side or even above/below is hard to look at and be sure you're lined up on the same moment.

@Fil
Copy link
Contributor

Fil commented Jun 1, 2022

It would be nice to have a few concrete examples to reason about.

For example, if we have two scales, one might be linear and the other log. Or one might be ordinal and the other temporal? (The only thing they share, in fact, is a common range.)

How would we indicate which scale is associated to which mark? Would a mark be able to use the two scales at once (for example to draw an arrow from (x1, y1) scaled with xa and ya to (x2, y2) scaled with xb and yb)?

(Using a normalisation map transform might help to solve the problem above, maybe?)

And there is the question of the dual axis: each axis would have to know what scale it represents, on which side it is, etc.

@papakpmartin
Copy link

I'm not sure if I'll answer your questions very well, but in the use case I had yesterday I was displaying two measurements (on Y axes) over time (X axis), for example, flow and conductivity mentioned above. This was extremely useful to identify certain effects as we modified the system.

Concerning Y scales, maybe I'm being foolish, but why not let either scale be whatever one wants? For example, if I'm exploring effects on a system, it could be really valuable to have one scale be linear and the other log because the nature of those two measured items might be that different, but their relationship over time might still be worth seeing.

I don't think one should be able to use both scales (like an arrow from one scale into the other). That doesn't make sense to me; but each mark having it's own scale makes pretty intuitive sense, I think.

As far as the each axis knowing question, I'd thought that the y: { axis: "right"... idea seems intuitive... maybe that can be moved inside a mark for these? Like maybe...

Plot.lineY(output_draw_data, {
  x: "timestamp",
  y: "value",
  stroke: "red",
  curve: "step-after",
  axis: "right",
 }),

I'm just riffing there... I know it's not that easy. But maybe calling out an axis there and then having y.axis optionally take an an object like...

Plot.plot({
  y: {
    "left":  { type: "log", nice: true, line: true, color: green },
    "right": { nice: false, line: true, color: orange }
  }
}

...would be clear and easy enough?

@papakpmartin
Copy link

So I guess I'm thinking something that acts like Vega-Lite's "resolve": {"scale": {"y": "independent"}}. Which does permit differing scale.types for each y axis/

@papakpmartin
Copy link

Any further consideration of this lovely idea? :)

(Guess who has some more dual-scale charts to make.)

@Fil
Copy link
Contributor

Fil commented Jul 14, 2022

I don't see us supporting several y scales in the near future, but we certainly want to find ways to ease the pain of doing dual-axis charts now.

I've added another alternative at the bottom of my notebook, showing how you can create a mark that return a D3 axis:
https://observablehq.com/@observablehq/dual-axis-bar-line-chart

@Fil Fil mentioned this issue Jul 14, 2022
@MarioDelgadoSr
Copy link

MarioDelgadoSr commented Nov 14, 2022

FWIW:

Despite Ms. Muth's recommendations/assertions ( https://blog.datawrapper.de/dualaxis/ ), dual-axis Pareto charts ( https://en.wikipedia.org/wiki/Pareto_chart ) offer high information-per-pixel.

See: Avoiding the Dual Axis Chart: The Exceptions: https://policyviz.com/2022/10/06/avoiding-the-dual-axis-chart

@Fil
Copy link
Contributor

Fil commented Mar 10, 2023

Vega-Lite has a notion of "independent" scales, as in https://vega.github.io/vega-lite/examples/layer_dual_axis.html
Related: #1247

@mbostock
Copy link
Member Author

Yes, I think we could do this by having a y1/y2 scale declared through a channel override. And then change implicit axes to draw axes for both scales.

@ezralee
Copy link

ezralee commented Jun 13, 2023

+1 as it's not always possible to convince stakeholders that there's "better" options

@MarkGStacey
Copy link

Certainly something I would like to use ~ e.g.g body fat percentage against weight is one example where the scales don't match up, but you want to overlay them to observe correlation

@papakpmartin
Copy link

Any progress or hints (other than what's been documented above)? Pro account user asking, FWIW. :)

@mbostock
Copy link
Member Author

@papakpmartin All progress is already shown above; we’re not hiding any secret progress! 😅 If you’re interested in this feature, please upvote by giving a 👍 reaction to the top post.

@mbostock
Copy link
Member Author

Here’s another take on a dual-axis chart: https://observablehq.com/@observablehq/plot-dual-axis

@Leftium
Copy link

Leftium commented May 17, 2024

Ref. https://blog.datawrapper.de/dualaxis/

So apparently the author of that article responded on HN: (emphasis mine)

Author here. Thanks for setting the context: Datawrapper – the data vis tool I write articles like this for – is indeed for people who want to make a point with their charts and maps, often to a broad audience. I agree that people who have learned to read dual axis charts can benefit greatly from them (the same is true for rainbow color maps).

Financial Times journalist John Burn Murdoch changed my mind on dual axes charts – even for casual readers! – a bit over the last six years, too. Here's a dual axis chart he created for the FT: https://x.com/AlexSelbyB/status/1529039107732774913

The next article I write on dual axis charts will probably be a "What to consider when you do use them" one.


Full Hacker News thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants