Skip to content

A few more ways to configure marker.size scales #2318

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

Closed
wants to merge 2 commits into from

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented Feb 1, 2018

This PR adds a few attributes to the marker container for scatter-like traces.

These new attributes are:

  • marker.sizemax: Sets the maximum size (in px) of the rendered marker points. Analogous to the existing marker.sizemax.
  • marker.sizedatamin: Sets the minimum marker.size value to be scaled. Values smaller than sizedatamin are displayed with sizemin.
  • marker.sizedatamax: Sets the maximum marker.size value to be scaled. Values greater than sizedatamin are displayed with sizemax.

and marker.sizemode has two new possible values:

  • 'log-diameter': the base10 log of the marker.size data is proportional to marker points' diameter .
  • 'log-area', the base10 log of the marker.size data is proportional to marker points' area.

Alternatively, we could add a new attribute (named e.g. marker.sizescaletype: 'linear' || 'log'), but while writing the description I thought that a looping log-scale settings into sizemode would be clearer for users.

cc @alexcjohnson

@greg9504
Copy link
Contributor

greg9504 commented Feb 7, 2018

Hello,
We hadn't heard from you so we had gone ahead and implemented this too. I've attempted to merge the two here:
https://github.com/greg9504/plotly.js
Your version does not handle negative values, and the log handling only converts the size data. The sizedatamin and sizedatamax should be converted too. See this commit:
greg9504@7ea8b88

The biggest difference is that sizeref is NOT used. Also I'm not too sure how the area mode is meant to be used.

Note I wasn't too sure when I started and I had modified the dist/plot-schema.json to indicate the new fields I added (sizedatamin etc). It's not quite up to date.

@etpinard
Copy link
Contributor Author

etpinard commented Feb 7, 2018

Hi @greg9504

First off, sorry for the wait. It's been a pretty crazy couple months in plotly.js land feature-wise.

Thanks for sharing your commit. It definitely makes it easier to understand what you're going after.


Now regarding the discrepancies between your commit and this PR:

Your version does not handle negative values

A while back, we (i.e me and. @alexcjohnson ) chose to ignore negative values in marker.size (i.e. making size=0) so that marker.size keeps its physical meaning if I remember correctly. Referencing the pre-open-source (private) PR here: https://github.com/plotly/streambed/pull/2947/

I'm not oppose to adding support for negative values in marker.size scales, but it would have to come under a new attribute to not break the current default behavior.

and the log handling only converts the size data. The sizedatamin and sizedatamax should be converted too

Personally, I thought sizedatamin and sizedatamax are more meaning if we keep them in true (i.e. not-log) data-space having the same units as the marker.size values. Would you mind sharing one of your use cases to enlighten us on the topic?

One more thing I noticed:

We can do better than sizedataislog which doesn't scale well. Let's say we want to add symlog scale option down the road (referencing #221)?. I thought all scale flavours could easily be encapsulated in marker.sizemode. What do you think?


Thanks for your help and patience. We're looking forward to having this feature part of plotly.js!

@greg9504
Copy link
Contributor

greg9504 commented Feb 7, 2018

Hello,
I can't read plotly/streambed#2947 but if I understand what you are saying is this a correct way of thinking of the current size array?:

  • array of integer values that are literal marker size values (physical meaning), and this is why negative values do not make sense.

What we had thought was that the size array could point to any type of data. In our case this can be measured data (things like temperature, pressure etc.) or calculated data. This data can have negative values, log scale etc. In the original proposal sent to Rob Williams it's clear that is what we intended, I believe we even provided some sample Matlab code to calculate the symbol sizes from the data values.

I can see from plotlys point of view that interpreting the marker.size array as literal marker sizes makes sense, and it keeps the interface simple. Perhaps there should have been another field called:
marker.sizedata - array field used to calculate marker.size values. If set Plotly handles filling in the marker.size array using the scaling method as implemented in my code?

As part of the proposal Plotly also needs to provide a marker size legend. Example from the proposal:
image

In order to create that legend and label it correctly the marker.sizedata, marker.sizedatamin, marker.sizedatamax, marker.sizemin, marker.sizemax, and the code to calculate the marker size are all needed.

I will post up a plot json config with some test data shortly.

@greg9504
Copy link
Contributor

Hello,
Any updates to this?

@etpinard
Copy link
Contributor Author

Closing (due to numerous merge conflicts). Discussion moved to -> #3129

@etpinard etpinard closed this Jan 15, 2019
@etpinard etpinard deleted the marker-size-scale branch January 15, 2019 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants