-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
DOC: lack of legend for ds.count_cat
#248
Comments
The colors were specified directly, per hour:
I.e., there are 24 colors in this list, starting with red, and each one is used in order for the 24 hours of the day starting at midnight (binning time by hour). The legends notebook shows how to add a legend. We're still working on it being less awkward to do all this (see issue #126). |
oh awesome! I didn't see that issue. Will there be any interest in just passing a For example, when I run the following code import pandas as pd
import datashader as ds
import datashader.transfer_functions as tf
from bokeh.plotting import output_notebook
df = pd.DataFrame(
{'x': [3, 3, 3, 6, 6, 6, 8, 8, 8],
'y': [2, 5, 8, 2, 5, 8, 2, 5, 8],
'group' : ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c']
}
)
df['group'] = df['group'].astype('category')
x_range, y_range = ((0, 10), (0, 10))
colors = ['#FF0000', "#00FF00", "#0000FF"]
plot_width = int(750)
plot_height = int(plot_width//1.2)
cvs = ds.Canvas(plot_width=plot_width, plot_height=plot_height,
x_range=x_range, y_range=y_range)
agg = cvs.points(df, 'x', 'y', ds.count_cat('group'))
img = tf.shade(agg, how='linear', color_key=colors)
tf.dynspread(img, threshold=0.2, max_px=4) I get the following image But when I run the following code df = pd.DataFrame(
{'x': [8, 3, 3, 6, 6, 6, 8, 8, 3],
'y': [5, 5, 8, 2, 5, 8, 2, 8, 2],
'group' : ['c', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'a']
}
)
df['group'] = df['group'].astype('category')
x_range, y_range = ((0, 10), (0, 10))
colors = ['#FF0000', "#00FF00", "#0000FF"]
plot_width = int(750)
plot_height = int(plot_width//1.2)
cvs = ds.Canvas(plot_width=plot_width, plot_height=plot_height,
x_range=x_range, y_range=y_range)
agg = cvs.points(df, 'x', 'y', ds.count_cat('group'))
img = tf.shade(agg, how='linear', color_key=colors)
tf.dynspread(img, threshold=0.2, max_px=4) I get the exact same image. So it doesn't look like the ordering of the categories in the dataframe matters. Which makes it a bit confusing with colors correspond to which categories. |
See the PR above, which provides a function to report which colors correspond to which categories. I'll merge that if there are no objections or test failures, and hopefully that will help! |
In the last figure in the NYC taxi cab notebook, the order of the colors were given
But it isn't clear exactly where this order of obtained. Was it obtained from the ordering of
df['hour']
? It would be really nice if we could have some sort of legend to explain the colors for these sorts of categories.The text was updated successfully, but these errors were encountered: