![]() ![]() Passing a GroupBy to the CDS is not going to be helpful for you, because that creates a CDS of the summarize data, but you want all the individual points. ![]() Marker=factor_mark('species', MARKERS, SPECIES),Ĭolor=factor_cmap('species', 'Category10_3', SPECIES)) P.scatter("petal_length", "sepal_width", source=flowers, legend_field="species", fill_alpha=0.4, size=12, UPDATE: The original answer below is still valid, but this kind of thing can now also be accomplished more easily with color and marker mapping transforms: from otting import figure, showįrom import flowersįrom ansform import factor_cmap, factor_mark Furthermore, how would I specify multiple symbols as requested? Without the groupby, color='color' actually works, but in my real example, the categorical variable has non-color values. This snippet presents the minimum needed. # source = plt.ColumnDataSource(df) - this would work for colorsįig.scatter('x', 'y', color='color', source=source) ![]() Source = plt.ColumnDataSource(df.groupby('color')) Here is a sample code to illustrate the problem: import pandas as pdĭf = pd.DataFrame(data=,, , However, the documentation primarily considers bar plots, and when I try to use the result of df.groupby('color') in ColumnDataSource, plotting 'x' and 'y' in scatter (with source=source) fails, because the column names 'x' and 'y' are not found. While I did find a solution where I extracted the relevant portions of 'x' and 'y' values manually, I thought it should be possible to do this in one command using "categorical" plotting in bokeh. Now I want to use bokeh to generate a scatter plot with different marker symbols ('red'->'x', 'green'->'o', and 'blue'->'triangle'). I have a pandas dataframe with two data columns (for simplicity let us call them 'x' and 'y'), and a categorical column (say 'color' with values 'red', 'green', and 'blue'). ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |