<jupyter_start><jupyter_text>Krisk is created for building statistical interactive visualization with pandas+Jupyter integration on top of Echarts.<jupyter_code>import pandas as pd
import krisk.plot as kk
# Use this when you want to nbconvert the notebook (used by nbviewer)
from krisk import init_notebook; init_notebook()<jupyter_output><empty_output><jupyter_text>We will be using GapMinder data for examples below.<jupyter_code>df = pd.read_csv('http://www.stat.ubc.ca/~jenny/notOcto/STAT545A/'
                              'examples/gapminder/data/'
                              'gapminderDataFiveYear.txt', sep='\t')

df.head()<jupyter_output><empty_output><jupyter_text>Let's start by small example. Using bar plot to count the data of category,<jupyter_code>kk.bar(df,'continent')<jupyter_output><empty_output><jupyter_text>Note that by default, the plot already used a tooltip. You can hover the plot to see the y-value. We also can plot bar by averaging GDP per capita for each continent,<jupyter_code>kk.bar(df,'continent',y='gdpPercap',how='mean')<jupyter_output><empty_output><jupyter_text>We can change x as year, and use the grouping on continent,<jupyter_code>kk.bar(df,'year',y='gdpPercap',c='continent',how='mean')<jupyter_output><empty_output><jupyter_text>Stacked and annotate the chart,<jupyter_code>(kk.bar(df,'year',y='gdpPercap',c='continent',how='mean',stacked=True,annotate=True)
 .set_size(width=1000))<jupyter_output><empty_output><jupyter_text>Next we can do the same thing with line chart, using area, annotate, and tooltip based on axis,<jupyter_code>p = kk.line(df,'year',y='gdpPercap',c='continent',how='mean',
           stacked=True,annotate='all',area=True)
p.set_tooltip_style(trigger='axis',axis_pointer='shadow')
p.set_size(width=1000)<jupyter_output><empty_output><jupyter_text>We can also create a histogram and add theme into it,<jupyter_code>p = (kk.hist(df,x='lifeExp',c='continent',stacked=True,bins=100))
p.set_tooltip_style(trigger='axis',axis_pointer='shadow')
p.set_theme('vintage')<jupyter_output><empty_output><jupyter_text>Let's get a little bit advanced. We're going to create scatter points of GapMinder data in 2007. We use Life Expectancy, GDP per Capita, and Population as x,y,size respectively. We also want to add the information on the tooltip, add and reposition toolbox, legend, and title.<jupyter_code>p = kk.scatter(df[df.year == 2007],'lifeExp','gdpPercap',s='pop',c='continent')
p.set_size(width=1000, height=500)
p.set_tooltip_format(['country','lifeExp','gdpPercap','pop','continent'])
p.set_theme('dark')
p.set_toolbox(save_format='png',restore=True,data_zoom=True)
p.set_legend(orient='vertical',x_pos='-1%',y_pos='-3%')
p.set_title('GapMinder of 2007',x_pos='center',y_pos='-5%')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13731128684399713, 'fraction_numerical': 0.012940330697340043, 'mean_word_length': 7.433333333333334, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '660568', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1027, 'n_tokens_neox': 973, 'n_words': 202, 'path': 'notebooks/Intro.ipynb', 'repo_name': 'JackEasons/krisk', 'size': '2782'}