spotify / chartify Goto Github PK
View Code? Open in Web Editor NEWPython library that makes it easy for data scientists to create charts.
License: Apache License 2.0
Python library that makes it easy for data scientists to create charts.
License: Apache License 2.0
Because they don't utilize _named_data_source. This probably applies to some of the other plot types as well.
Is there is a way to avoid chromedriver install to just render png output?
Is this possible to switch to another way of generating pngs?
What's advantage of crhomedriver?
ps. I also noticed selenium dependency - how is chartify related to automated testing?
Thanks!
Request for Example of stacked horizontal bar chart from pandas groupby object, preferably with red/green for good/bad values for each bar.
Why? I can't get this to work in matplotlib 2.0, which seems to choke on this code
Is this a BUG REPORT or FEATURE REQUEST?:
Uncomment only one, leave it on its own line:
type: feature
Environment:
What happened:
See https://stackoverflow.com/questions/53583715/trying-to-print-two-color-stacked-barh-using-matplotlib for details.
Note the issue seems to be creating the graph properly from a pandas groupby object.
Here is the unredacted code
if 'Incomplete Evidence' in df.Evaluation:
gb = df.groupby(group_by).Evaluation.value_counts(
).unstack(level=-1).nlargest(limit, columns='Incomplete Evidence').stack()
elif 'Complete Evidence' in df.Evaluation:
gb = df.groupby(group_by).Evaluation.value_counts(
).unstack(level=-1).nlargest(limit, columns='Complete Evidence').stack()
else:
gb = df.groupby(group_by).Evaluation.value_counts()
.# rbar = [x for x in gb.unstack(level=-1)['Incomplete Evidence']]
.# gbar = [x for x in gb.unstack(level=-1)['Complete Evidence']]
. ### Temporarily using a bar chart
chart = gb.unstack(level=-1).plot.bar(color=chart_colors, stacked=True)
.# chart = plt.barh(0, rbar, color='r')
.# chart = plt.barh(1, gbar, left=rbar, color='g')
What you expected to happen:
A normal horizontal stacked bar with red/green from a groupby object.
How to reproduce it (as minimally and precisely as possible):
See code above - no way to create object in matplotlib to work as expected.
Anything else we need to know?:
import chartify
data = chartify.examples.example_data()
quantity_by_fruit = (data.groupby('fruit')['quantity'].sum().reset_index())
print(quantity_by_fruit.head())
quantity_by_fruit.iloc[0,0] = 'AAAAAAAAAAAAAAAAAAAA'
ch = chartify.Chart(False, y_axis_type='categorical')
ch.set_title("Vertical bar plot")
ch.plot.bar(
data_frame=quantity_by_fruit,
categorical_columns='fruit',
numeric_column='quantity')
ch.show()
Hi,
I've an issue regarding how to print the legend with a simple set of data like below:
accel_speed accel_g1 accel_g2 accel_g3 accel_g4 accel_g5 accel_g6
0 0 0.000000 0.000000 0.000000 0.000000 0.0 0.0
1 1 0.000000 0.000000 0.000000 0.000000 0.0 0.0
2 2 0.000000 0.000000 0.000000 0.000000 0.0 0.0
3 3 0.000000 0.000000 0.000000 0.000000 0.0 0.0
4 4 0.000000 0.000000 0.000000 0.000000 0.0 0.0
5 5 0.000000 0.000000 0.000000 0.000000 0.0 0.0
6 6 2.813216 0.000000 0.000000 0.000000 0.0 0.0
7 7 3.653817 0.000000 0.000000 0.000000 0.0 0.0
8 8 2.807802 0.000000 0.000000 0.000000 0.0 0.0
9 9 2.312193 0.555871 0.000000 0.000000 0.0 0.0
10 10 3.660337 1.154770 0.000000 0.000000 0.0 0.0
that I would like to line plot as accel_speed
vs accel_gX
, so currently I'm the code below to fill the chart
for k in data.keys():
if k != 'accel_speed':
ch.plot.line(data_frame=df, y_column=k, x_column='accel_speed')
But I don't know how to specify the legend. Finally is there a way to plot such multi column data in one shot such as ch.plot.multi_line()
?
Thank you,
Roberto Fichera.
Null values automatically get cast to zero. It would be good to give users the ability to drop them.
Thanks galmeida!
Could you please also publish chartify to conda ? Not just to pip.
Thank you.
When plotting bar charts the color_column must be contained in the categorical columns. For use cases that include highlighting specific values it's not always preferable to have the color dimension on the axis.
Would be good to look into whether this adjustment should be made to the other categorical plots as well (stacked bar, interval, parallel, scatter, etc)
Is this a BUG REPORT or FEATURE REQUEST?:
type: feature
Box-and-whisker plots are useful tools for statistical analysis and data presentation. It would be very useful if the feature could be added.
Is this a BUG REPORT or FEATURE REQUEST?:
Not quite sure, but I guess feature
type: feature
What happened:
I intend to plot an unstacked area chart, to compare different evolutions are respective results. With different areas not having all the same amount of rows.
Meaning, for instance, area A1 can go from 1 to 10 but area A2 may only have values from 1 to 8.
What is currently built now always assumes "nan" values to be considered 0, while this is not true and displays incorrect information.
Attachment 1 will shows the problem above.
What you expected to happen:
I expect the areas to stop their plot when there are no more X values belonging to them, instead of assuming 0.
How to reproduce it (as minimally and precisely as possible):
Create a dataset where one of the group_by columns does not contain the same amount of values as others
If any other information is required please let me know.
Thank you
Example:
import pandas as pd
import numpy as np
import chartify
df = pd.DataFrame({'values': [1000, 10, 100, 20]})
df['labels'] = df['values']
# breaks
ch = chartify.Chart(x_axis_type='categorical', y_axis_type='log')
ch.plot.bar(df, 'labels', 'values')
ch.show()
# works
factors = [str(x) for x in [1000, 100, 10, 1]]
ch = chartify.Chart(x_axis_type='categorical', y_axis_type='log')
ch.plot._set_categorical_axis_default_factors(True, factors)
ch.figure.vbar(x=factors, top=[1000, 100, 10, 1], bottom=0.1, width=1, fill_color='blue')
ch.show()
Related to:
bokeh/bokeh#6671
bokeh/bokeh#6536
Getting started area, and the more examples links in the readme are broken when read on https://pypi.org/project/chartify/.
Is this a BUG REPORT or FEATURE REQUEST?:
type: feature
Anything else we need to know?:
A tutorial using mybinder.org (like bokeh's tutorial) makes it much more convenient to test the library before installing it.
For vertical legends, the legend sort order is the reverse of the area plotting order. The default order should be changed to be made consistent.
Probably worth checking how this works with other plot types as well:
Is this a BUG REPORT or FEATURE REQUEST?:
type: bug
Environment:
What happened:
If ch.set_legend_location("outside_top")
is evaluated after a subtitle is created, it will cover the subtitle. Not an issue if the subtitle is created after ch.set_legend_location("outside_top")
.
What you expected to happen:
Expected subtitle to appear
How to reproduce it (as minimally and precisely as possible):
Create a chart with a subtitle then add the legend to "outside_top"
Anything else we need to know?:
It's still possible to have both subtitle and outside_top
legend if the subtitle is added afterwards.
Is this a BUG REPORT or FEATURE REQUEST?:
Uncomment only one, leave it on its own line:
type: bug
type: feature
Environment:
What happened:
I'm getting an extra two orders of magnitude (or more if I set a floating point on the tick value) for values with floating points in stacked bar charts.
What you expected to happen:
When setting the y axis tick values to '0%", I should get percentage values ranging from 0-100%.
How to reproduce it (as minimally and precisely as possible):
Plot all chromosome data using stacked bar plot
RdGy = chartify.color_palettes['RdGy']
shifted_RdGy = RdGy.shift_palette('black', percent=20)
shifted_RdGy.show()
(chartify.Chart(blank_labels=True,
x_axis_type='categorical')
.style.set_color_palette('diverging', palette=shifted_RdGy)
.plot.bar_stacked(
data_frame=results,
categorical_columns='#ID',
categorical_order_by='labels',
categorical_order_ascending=True,
numeric_column='Covered_percent',
stack_column='sample',
normalize=False)
.set_legend_location('outside_right', orientation='vertical')
.axes.set_yaxis_tick_format('0.0%')
.axes.set_xaxis_tick_orientation('vertical')
.show('png'))
Anything else we need to know?:
Included the df and ipynb if you want to replicate.
Allen_concatData.txt
pileup.zip
Is there any way to have the charts render on web so I can style and animate them on the fly and potentially make them interactive with data from my database?
Allow users to create heatmap plots directly from cross-tabbed data without needing to melt the input data.
ch = chartify.Chart()
ch.figure.circle([1, 2, 3], [1, 2, 3])
ch.set_title('hi')
ch.save('test.html', 'html')
ch.show()
RuntimeError: Models must be owned by only a single document, Circle(id='1668', ...) is already in a doc
Hi,
Just an FYI that projects downstream from Bokeh (such as Dask and Holoviews) have begun contributing minimal Bokeh-specific test suites to the Bokeh project to run during our Continuous Integration testing. Certainly we intend not to make any breaking changes at this point, but the "downstream" tests allow us to be extra careful not to disturb any downstream projects. (These tests are currently advisory-only in order to avoid too-tight coupling between project state, but we observe the results regularly).
I'd like to invite you to contribute a test suite for Chartify. The relevant files are here:
https://github.com/bokeh/bokeh/blob/master/scripts/ci/install.downstream
https://github.com/bokeh/bokeh/blob/master/scripts/ci/test.downstream
I'm happy to answer any questions or assist however I can.
unable to chartify in notebook environment due to below errow.
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
I believe that heatmap lacks an order
parameter for categories. The values are sorted the way they occur in the data frame (?), which is not very convenient.
type: bug
Environment:
What happened:
Calling line method with all 0 y_column raises OverflowError
What you expected to happen:
Return an instance of chart
How to reproduce it (as minimally and precisely as possible):
import chartify
import pandas as pd
df = pd.DataFrame(data={'col1': [1, 2, 3], 'col2': [0, 0, 0]})
ch = chartify.Chart()
ch.plot.line(data_frame=df,
x_column='col1',
y_column='col2')
Thanks for finding @Danela!
label_test = pd.DataFrame({'value': [.20, .40, .05, .6, .2, .8],
'bucket': [1, 2, 3, 1, 2, 3],
'platform': ['android', 'android', 'android', 'ios', 'ios', 'ios'],
'value2': [1.0, 2.0, 3, 6., 8., 10.]
})
ch = chartify.Chart(x_axis_type='categorical')
ch.plot.bar(label_test, ['bucket', 'platform'], 'value')
ch.plot.text(label_test, ['bucket', 'platform'], 'value', 'value2')
ch.show()
I guess its more a question than a feature request:
The data:
data1 = np.random.normal(0, 0.1, 1000)
data2 = np.random.normal(1, 0.4, 1000) + np.linspace(0, 1, 1000)
data3 = 2 + np.random.random(1000) * np.linspace(1, 5, 1000)
data4 = np.random.normal(3, 0.2, 1000) + 0.3 * np.sin(np.linspace(0, 20, 1000))
data = np.vstack([data1, data2, data3, data4]).transpose()
df = pd.DataFrame(data, columns=['data1', 'data2', 'data3', 'data4'])
df.head()
data1 | data2 | data3 | data4 | |
---|---|---|---|---|
0 | -0.216306 | 0.769149 | 2.614268 | 3.022906 |
1 | 0.091122 | 2.037440 | 2.135203 | 3.127771 |
2 | 0.076178 | 0.983550 | 2.278488 | 2.970982 |
3 | -0.023629 | 1.859270 | 2.005969 | 2.986248 |
4 | 0.076633 | 1.453625 | 2.120465 | 2.805301 |
now, plotting in Pandas is done like that:
df.plot(title='Line plot')
The unnamed dataframe-index is automatically used for the x-axis.
Question: Would it be possible to have a similar behaviour in chartify?
ch = chartify.Chart(blank_labels=True, x_axis_type='linear')
ch.plot.line(
# Data must be sorted by x column
data_frame=df,
x_column= "index", # internally do a df.index.get_values() or just the fixed term "index"?
y_column="value",
color_column="variable")
According to the tidy data paradigm, this solution works. But it seeems like a lot of extra miles to get the same result like in pandas:
melted_data = pd.melt(df.reset_index(),
id_vars='index',
value_vars=df.columns)
ch = chartify.Chart(blank_labels=True, x_axis_type='linear')
ch.plot.line(
data_frame=melted_data,
x_column= "index",
y_column="value",
color_column="variable")
I have the feeling i won't be the last person to ask exactly this queston about grabbing the index-data. ;-)
Label orientation method requires bokeh >= 0.12.16
Uncomment only one, leave it on its own line:
type: bug
type: feature
It would be nice to allow users to specify their own Bokeh resource loading. I believe it would be possible to implement this by having the import chartify
invocation defer to a previous call to bokeh.io.output_notebook
.
This would enable users to:
This would almost make chartify work in different notebook contexts, by letting users specify
output_notebook(notebook_type='zeppelin')
Example code:
# user specifies their own bokeh/notebook configuration
from bokeh.io import output_notebook
output_notebook()
# load chartify package into namespace but defer to above bokeh.io.output_notebook call
import chartify
Otherwise users will get a blank chart with no explanation.
Create a text plot method for dual categorical axes to add move flexibility to heatmap labeling.
Example use case here:
https://stackoverflow.com/questions/54502504/how-to-display-data-from-two-columns-in-chartify-heatmap/54577536#54577536
Currently the _get_svgs and _figure_to_png methods have code copied from bokeh.io.export. I stripped out the wait_until_render_complete functions because I couldn't figure out a quick way to get it to work with chromedriver. Probably worth restoring at some point.
Is this a BUG REPORT or FEATURE REQUEST?:
Uncomment only one, leave it on its own line:
type: bug
type: feature
Environment:
What happened:
Tried to change the xaxis tick orientation of a plot with x_axis_type = 'datetime'
I am able to change the orientation for other plot types I've used
What you expected to happen:
x-axis tick orientation to change as it does for other types of plot
How to reproduce it (as minimally and precisely as possible):
Create a datetime chart and try to change its axis tick orientation
Anything else we need to know?:
traceback:
AttributeError Traceback (most recent call last)
<ipython-input-47-1e689c0d8eb9> in <module>()
28 monthyearch.axes.set_yaxis_label('Number of Reported Crimes')
29 # monthyearch.axes.set_xaxis_tick_values(pd.date_range('2014-01-31', '2017-12-31', freq='6M'))
---> 30 monthyearch.axes.set_xaxis_tick_orientation('diagonal')
31
32
c:\users\simon\appdata\local\programs\python\python37-32\lib\site-packages\chartify\_core\axes.py in set_xaxis_tick_orientation(self, orientation)
192
193 self._chart.figure.xaxis.major_label_orientation = level_1
--> 194 self._chart.figure.xaxis.subgroup_label_orientation = level_2
195 self._chart.figure.xaxis.group_label_orientation = level_3
196 return self._chart
c:\users\simon\appdata\local\programs\python\python37-32\lib\site-packages\bokeh\models\plots.py in __setattr__(self, attr, value)
36 def __setattr__(self, attr, value):
37 for x in self:
---> 38 setattr(x, attr, value)
39
40 def __dir__(self):
c:\users\simon\appdata\local\programs\python\python37-32\lib\site-packages\bokeh\core\has_props.py in __setattr__(self, name, value)
287
288 raise AttributeError("unexpected attribute '%s' to %s, %s attributes are %s" %
--> 289 (name, self.__class__.__name__, text, nice_join(matches)))
290
291 def __str__(self):
AttributeError: unexpected attribute 'subgroup_label_orientation' to DatetimeAxis, similar attributes are major_label_orientation
Is this a BUG REPORT or FEATURE REQUEST?:
type: feature
Maybe this is already possible with Chartify and I missed it, but it would be great if Chartify provided an easy way to overlay/add horizontal and vertical lines (of different colors, different dash patterns) to a graph! e.g. to represent levels, or dates of specific events, on the graph.
Is this a BUG REPORT or FEATURE REQUEST?:
Uncomment only one, leave it on its own line:
type: bug
type: feature
Environment:
What happened:
jupyter notebook, tried to import charify
ImportError: DLL load failed: The specified module could not be found.
What you expected to happen:
charitify to import
How to reproduce it (as minimally and precisely as possible):
get the error anytime I try to import charity, I uninstalled it and reinstalled via pip still same error
Anything else we need to know?:
ImportError Traceback (most recent call last)
in ()
----> 1 import chartify
C:\Users\msavage\AppData\Local\Continuum\anaconda3\lib\site-packages\chartify_init_.py in ()
15 # limitations under the License.
16 """Top-level package for chartify."""
---> 17 from chartify._core.chart import Chart
18 from chartify._core.colors import color_palettes
19 from chartify._core.options import options
C:\Users\msavage\AppData\Local\Continuum\anaconda3\lib\site-packages\chartify_core\chart.py in ()
24
25 import bokeh
---> 26 import bokeh.plotting
27 from bokeh.embed import file_html
28
C:\Users\msavage\AppData\Local\Continuum\anaconda3\lib\site-packages\bokeh\plotting_init_.py in ()
1 # this is just for testing, otherwise the figure module is shadowed
2 # by the figure function and inacessible
----> 3 from . import figure as _figure
4
5 # extra imports -- just things to add to 'from bokeh.plotting import'
C:\Users\msavage\AppData\Local\Continuum\anaconda3\lib\site-packages\bokeh\plotting\figure.py in ()
6 from six import string_types
7
----> 8 from ..core.properties import Any, Auto, Either, Enum, Int, List, Seq, Instance, String, Tuple
9 from ..core.enums import HorizontalLocation, MarkerType, VerticalLocation
10 from ..models import ColumnDataSource, Plot, Title, Tool, GraphRenderer
C:\Users\msavage\AppData\Local\Continuum\anaconda3\lib\site-packages\bokeh\core\properties.py in ()
254 from .property.container import RelativeDelta; RelativeDelta
255
--> 256 from .property.dataspec import AngleSpec; AngleSpec
257 from .property.dataspec import ColorSpec; ColorSpec
258 from .property.dataspec import DataSpec; DataSpec
C:\Users\msavage\AppData\Local\Continuum\anaconda3\lib\site-packages\bokeh\core\property\dataspec.py in ()
39 from .instance import Instance
40 from .primitive import Float, String
---> 41 from .visual import FontSize, MarkerType
42
43 #-----------------------------------------------------------------------------
C:\Users\msavage\AppData\Local\Continuum\anaconda3\lib\site-packages\bokeh\core\property\visual.py in ()
28
29 # External imports
---> 30 import PIL.Image
31 from six import string_types
32
C:\Users\msavage\AppData\Local\Continuum\anaconda3\lib\site-packages\PIL\Image.py in ()
56 # Also note that Image.core is not a publicly documented interface,
57 # and should be considered private and subject to change.
---> 58 from . import _imaging as core
59 if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None):
60 raise ImportError("The _imaging extension was built for another "
ImportError: DLL load failed: The specified module could not be found.
FEATURE REQUEST
E.g.:
ch.plot.scatter(
data_frame=price_and_quantity_by_country,
x_column='total_price',
y_column='quantity',
color_column='country')
ch.plot.text(
data_frame=price_and_quantity_by_country,
x_column='total_price',
y_column='quantity',
text_column='country',
color_column='country',
x_offset=1,
y_offset=-1,
font_size='10pt')
I understand there is a very good reason to separate the data- and the text-plot, but wouldn't it be more efficient to inject the text-marker-"data" directly into scatter.plot, or any kind of plot?
Like a switch. If text data is present, render the data & text?
Something like this:
ch.plot.scatter(
data_frame=price_and_quantity_by_country,
x_column='total_price',
y_column='quantity',
color_column='country',
text_column='country',
x_offset=1,
y_offset=-1,
font_size='10pt')
Currently only accepts lists.
Thanks for finding Dominic Fitzgerald!
Is this a BUG REPORT or FEATURE REQUEST?:
type: feature
Currently, when attempting to use gridplot with Chartify (as a list of charts), it returns "AttributeError: 'Chart' object has no attribute 'select'." When attempting the same with bokeh.layouts.layout, it returns "ValueError: Only LayoutDOM items can be inserted into a layout."
It would be great to have this feature integrated to show/export many chart objects at once.
The plot methods apply default formatting. As a result the user-applied formatting methods can seem to not work if they're applied before plotting and thus overwritten. Make the order of operations clearer, or provide a warning if the user-supplied default is overwritten, or ideally only apply the defaults if there is no user-supplied formatting.
Is it possible to change the font family for the entire plot?
THIS IS FEATURE REQUEST
Environment:
I suggest to support the with statement in the following way:
import chartify
import pandas
class Chart(chartify.Chart):
def __enter__(self):
return self
def __exit__(self, type, value, traceback):
self.show()
df = pandas.DataFrame({'x': [1, 2, 3], 'y': [1, 2, 3]})
with Chart() as ch:
ch.plot.line(df, 'x', 'y')
ch.set_title("Example")
This would allow a very simple and clean way of structuring one's plots.
Uncomment only one, leave it on its own line:
type: bug
type: feature
Bokeh added the "BokehJS x.y.z successfully loaded." banner because loading resources from the CDN is the default loading strategy and we wanted to inform users if BokehJS failed to load (which can happen due to networks issues or other reasons). Then users can self-diagnose when their plots don't appear after calling bokeh.io.show
.
Since Chartify inlines the Bokeh resources, there isn't the risk to BokehJS not being loaded and I think the banner could be confusing to users via:
bokeh
isn't in my namespace"All-in-all, it feels cleaner to hide the BokehJS banner.
Question seems to come up a lot. Example solution:
outside_groups = ['heavy', 'light', 'etc']
inner_groups = ['US', 'JP', 'CA']
sort_order = list(product(outside_groups, inner_groups))```
Then `categorical_order_by=sort_order`
type: feature
I have a use case where I would like to create a scatter plot that is color coded by a categorical variable, and include some other text in the tooltip. Currently, I am unable to do this with Chartify because the data frame I pass in has extra columns stripped from it, so they are not available to the tooltip. If you could either not strip those columns out, or add a parameter to the scatter plot function that would allow me to keep a text column, such as label_column
it would be very helpful.
Here's an example to illustrate the issue:
I have a dataframe, df
, that looks like:
x | y | l | t |
---|---|---|---|
1 | 4 | a | 'Sunflower' |
2 | 5 | b | 'Shallow' |
3 | 6 | c | 'thank you, next' |
I would like t
column to appear in a tooltip in a scatter plot with the following code:
import pandas as pd
import chartify
from bokeh.models import HoverTool
df = pd.DataFrame({'x': [1, 2, 3],
'y': [4, 5, 6],
'l': ['a', 'b', 'c'],
't': ['Sunflower', 'Shallow', 'thank you, next']})
ch = chartify.Chart(blank_labels=True)
ch.plot.scatter(
data_frame=df,
x_column='x',
y_column='y',
color_column='l')
hover = HoverTool(tooltips=[
("Title", '@t'),
("Cluster", "@l"),
])
ch.figure.add_tools(hover)
ch.show()
But what happens is that the tooltip shows "Title: ???, Cluster: a". As far as I can tell, there is no way to pass in a list of text to HoverTool
-- it has to be a part of the ColumnDataSource
.
It looks like the internals of PlotNumericXY.scatter
is filtering out columns here. Is this necessary? Can it be made optional?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.