<jupyter_start><jupyter_text>Installation`micplot` can be installed by forking this repository and running `pip install micplot` in the appropriate folder. The only requirements are `pandas` and `matplotlib`. More effective visualization in one line of codePandas is  an extremely popular python package for data manipulation, and for good reason: it has a host of possibilities. However, it's out-of-the-box plotting options usually result in hard to interpret plots. This is unfortunate, because good visualization leads to better discussion with and more insights from subject matter experts, which is sorely needed for useful data analytics<jupyter_code>import os

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

import micplot
df = pd.read_csv(os.path.join('..', 'data', 'titanic.csv'))
data = df.groupby('Embarked')['Fare'].mean()
data.plot() 
plt.show()<jupyter_output><empty_output><jupyter_text>Indeed, the plot is difficult to interpret. A line plot is a poor choice for this type of data, there are meaningless ticks, and no axis label.Therefore, the `micplot` package was developed, with three advantages:  1. It automatically makes choices that make the plot much easier to interpret  1. It makes the up the plot area nicely, by removing fluff, so it is easer to read.  1. It is fully customizable if something is not to your wishes   Creating focusIn plotting, it is important to make clear what the point of the plot is. `micplot` does this in two ways:1. From the data, it infers a focus point, by sorting and highlighting data, and  1. It makes the plot clearer, by annotating when necessary and removing fluff, such as unnecessary ticks and the frame.<jupyter_code>vis = micplot.visualize(data)
plt.show()<jupyter_output><empty_output><jupyter_text>The plot is still fully customizableIf the plot is not fully to your liking, the `Visualization` object that is returned contains all choices as attributes, including the axis, which can still be altered. In the example below, we alter the plottype and the bars which are highlighted.<jupyter_code>vis = micplot.visualize(data, plottype='vertical_bar', highlight=[0, 1])
vis.ax.set_ylabel('Mean ticket price')
plt.show()<jupyter_output><empty_output><jupyter_text>Other options that can be altered are in the documentation:<jupyter_code>?micplot.Visualization<jupyter_output><empty_output><jupyter_text>`micplot` contains some more useful plottypesAbove, we already saw the bar chart that is often very useful to make a point. Below, we show other plottypes and when `micplot` uses them. Waterfall charts for compositionsWaterfall charts are a good choice to show how the total group composition is. Note how `micplot` automatically infers this from the fact that the data contains percentages that add up to 100%.<jupyter_code>data = df['Embarked'].value_counts(normalize=True)
micplot.visualize(data)
plt.show()<jupyter_output><empty_output><jupyter_text>Vertical bars for short timeseries dataBar charts are the plot of choice for time series data with not too many points. `micplot` infers this from the Index of the data. Note how in the plot below the legend is placed outside the plot to prevent the legend from overlapping with the data. The highlight specifies that data point to highlight if there is only one Series, but the column to highlight if multiple Series are compared.<jupyter_code>size = 6
columnnames = ['Cars', 'Bikes', 'Buses', 'Planes']
test_data = pd.DataFrame(10*np.random.rand(size, 4), index=pd.date_range('20190101', periods=size), columns=columnnames)
micplot.visualize(test_data['Cars'], highlight=-1)
plt.show()
micplot.visualize(test_data, highlight=0)
plt.show()<jupyter_output><empty_output><jupyter_text>Line chart for longer timeseries dataThe bar chart would become unreadable if the time series data were longer, so `micplot` changes the plottype to a line plot.<jupyter_code>size = 12
test_data = pd.DataFrame(10*np.random.rand(size, 4), index=pd.date_range('20190101', periods=size), columns=columnnames)

micplot.visualize(test_data['Cars'], highlight=-1)
plt.show()
micplot.visualize(test_data, highlight=0)
plt.show()<jupyter_output><empty_output><jupyter_text>Scatter plots to investigate the relationship between two series<jupyter_code>micplot.visualize(df[['Age', 'Fare']])
plt.show()<jupyter_output><empty_output><jupyter_text>If there are only a few datapoints in the plot, the points are also labeled with their index.<jupyter_code>micplot.visualize(df[['Age', 'Fare']].sample(15))
plt.show()<jupyter_output><empty_output><jupyter_text>If there is a third column, this is turned into a bubble chart, where the third column determines the marker size. Here we see that `micplot` gives the legend a title when appropriate.<jupyter_code>micplot.visualize(df[['Age', 'Fare', 'Parch']])
plt.show()<jupyter_output><empty_output><jupyter_text>Composition comparison can show how subpopulations differIf we quickly want to infer whether subgroups have the same distribution, we can use a stacked bar chart. `micplot` automatically chooses this if the data to visualize is a DataFrame where each column is a percentage Series.<jupyter_code>data = (df.groupby('Pclass')['Survived'].value_counts(normalize=True)
        .unstack(level='Pclass')
       )
display(data)
vis = micplot.visualize(data)<jupyter_output><empty_output><jupyter_text>Pie chart works as expected<jupyter_code>micplot.visualize(df['Embarked'].value_counts(), plottype='pie')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08569353667392883, 'fraction_numerical': 0.007443718228031954, 'mean_word_length': 6.325797872340425, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '666312', 'license': 'MIT', 'n_tokens_mistral': 1653, 'n_tokens_neox': 1569, 'n_words': 628, 'path': 'readmefigs/README.ipynb', 'repo_name': 'SjoerdCor/micplot', 'size': '5508'}