I want to display a bar plot comparing algorithms from different publications.
The data has the following properties:
- Year of publication ( This is what I want my x axis to be)
- Score (This is the bar height)
- Data type (this will set the color for each bar)
I am having trouble making this happen (haven't gotten to enforce the 3rd demand).
Here is an example data and code :
import numpy as np
import matplotlib.pyplot as plt
dtypes = ['type1', 'type2', 'type3']
names = ['name1','name2','name3', 'name4']
score = [89.2, 95.54, 85, 86]
years = [2016, 2017, 2016, 2015]
methods_dtype = ['type1', 'type2', 'type1', 'type1']
pub_years = np.unique(years)
fig, ax = plt.subplots()
barplot = ax.bar(years, score)
plt.show()
The first problem here is that the two bars of 2016 are on top of each other ( I saw some examples that move the bars incrementally using the width, however, in this case, I do not know beforehand how many methods would be in that year).
The second problem is coding the colors.
Note that the input is just a subset of the data. There may be a year with multiple entries (more than one publication for a specific year). There may also be a data type with multiple entries (more than one method that operates on this data type).
seaborn.barplot