Package: barplots
Python package to easily make barplots from multi-indexed dataframes.How do I install this package?As usual, just download it using pip:pipinstallbarplotsDocumentationMost methods, in particular those exposed to user usage, are provided with doc strings.
Consider reading these docstrings for learning the most recent updates to the library.Examples of the DataFrame structureThe dataframe to be provided to the barplots library may looks like the following:miss_ratefall_outmccevaluation_typeunbalancegraph_namenormalization_name0.03320310.7050780.353357train10AlligatorSinensisTraditional0.2402340.4785160.289591train1CanisLupusRight Laplacian0.02539060.9316410.101643train100AlligatorSinensisRight Laplacian0.1210940.6992190.220219train10HomoSapiensTraditional0.01367190.2929690.722095test1CanisLupusRight Laplacian0.06054690.906250.0622185test10AmanitaMuscariaKoideBx008Traditional0.00781250.43750.614287train100AmanitaMuscariaKoideBx008Traditional0.1718750.869141-0.0572194train100AlligatorSinensisTraditional0.08593750.8105470.150206train10MusMusculusRight Laplacian0.02734380.6464840.415357test10MusMusculusRight LaplacianSpecifically, in this example, we may create bar plots for the features Miss rate, fallout and Matthew Correlation Coefficient
by grouping on the evaluation_type, unbalance, graph_name and normalization_name columns.An example CSV file can be seenhere.Usage examplesHere follows a set of examples of common usages. Basically, every graph show either the same data
or a mean based on the provided group by indices. Choose whetever representation is best for
visualizing your data, as hardly one is better than another for every possible dataset.N.B. The data used in the following examples arerandomly generatedso to be useful for test porposes.DO NOTconsider these values as valid results for experiments using the same labels (cell lines etc…)
which are only used to show possible usages.For every example, the considered dataframedfis loaded as follows:importpandasaspddf=pd.read_csv("tests/test_case.csv")Also, for every example, thecustom_defaultsused to sanitize the labels specific to the used dataset is:custom_defaults={"P":"promoters","E":"enhancers","A":"active ","I":"inactive ","+":" and ","":"anything","Validation":"val"}Horizontal Example AIn the following example we will plot the bars horizontally, rotating the group labels by 90 degrees and
displaying the bar labels as a shared legend.frombarplotsimportbarplotsbarplots(df,groupby=["task","model"],orientation="horizontal",show_legend=True,minor_rotation=90,custom_defaults=custom_defaults)Result can be seenhere.Horizontal Example BIn the following example we will plot the top index as multiple
subplots with horizontal bars, rotating the group labels by 90 degrees and
displaying the bar labels as a shared legend.frombarplotsimportbarplotsbarplots(df,groupby=["cell_line","task","model"],orientation="horizontal",show_legend=True,subplots=True,minor_rotation=90,custom_defaults=custom_defaults)Horizontal Example CIn the following example we will plot horizontal bars, rotating the top group labels by 90 degrees and
displaying the bar labels as minor ticks.frombarplotsimportbarplotsbarplots(df,groupby=["task","model"],orientation="horizontal",show_legend=False,major_rotation=90,custom_defaults=custom_defaults)Result can be seenhereHorizontal Example DIn the following example we will plot the top index as multiple
subplots with horizontal bars, rotating the group labels by 90 degrees and
displaying the bar labels as minor ticks.frombarplotsimportbarplotsbarplots(df,groupby=["cell_line","task","model"],orientation="horizontal",show_legend=False,major_rotation=90,subplots=True,custom_defaults=custom_defaults)Vertical Example AIn the following example we will plot the bars vertically and
displaying the bar labels as a shared legend.frombarplotsimportbarplotsbarplots(df,groupby=["task","model"],orientation="vertical",show_legend=True,custom_defaults=custom_defaults)Result can be seenhereVertical Example BIn the following example we will plot the top index as multiple
subplots with vertical bars  and displaying the bar labels as a shared legend.frombarplotsimportbarplotsbarplots(df,groupby=["cell_line","task","model"],orientation="vertical",show_legend=True,subplots=True,custom_defaults=custom_defaults)Vertical Example CIn the following example we will plot vertical bars, rotating the minor group labels by 90 degrees and
displaying the bar labels as minor ticks.frombarplotsimportbarplotsbarplots(df,groupby=["task","model"],orientation="vertical",show_legend=False,minor_rotation=90,custom_defaults=custom_defaults)Result can be seenhereVertical Example DIn the following example we will plot the top index as multiple
subplots with vertical bars, rotating the minor group labels by 90 degrees and
displaying the bar labels as minor ticks.frombarplotsimportbarplotsbarplots(df,groupby=["cell_line","task","model"],orientation="vertical",show_legend=False,minor_rotation=90,subplots=True,custom_defaults=custom_defaults)Future featuresCurrently it is not possible to automatically detect labels overlap and rotate them.
I will work on this feature when I get the time, currently you will need to use the parametersminor_rotationandmajor_rotation.