Does it work for Bar-type plot?
karimmd opened this issue · 1 comments
karimmd commented
I would like to ask whether we can use SciencePlot on Bar-type plots or not. Thanks.
For example:
import numpy as np
import matplotlib.pyplot as plt
# set width of bar
barWidth = 0.25
fig = plt.subplots(figsize =(12, 8))
# set height of bar
IT = [12, 30, 1, 8, 22]
ECE = [28, 6, 16, 5, 10]
CSE = [29, 3, 24, 25, 17]
# Set position of bar on X axis
br1 = np.arange(len(IT))
br2 = [x + barWidth for x in br1]
br3 = [x + barWidth for x in br2]
# Make the plot
plt.bar(br1, IT, color ='r', width = barWidth,
edgecolor ='grey', label ='IT')
plt.bar(br2, ECE, color ='g', width = barWidth,
edgecolor ='grey', label ='ECE')
plt.bar(br3, CSE, color ='b', width = barWidth,
edgecolor ='grey', label ='CSE')
# Adding Xticks
plt.xlabel('Branch', fontweight ='bold', fontsize = 15)
plt.ylabel('Students passed', fontweight ='bold', fontsize = 15)
plt.xticks([r + barWidth for r in range(len(IT))],
['2015', '2016', '2017', '2018', '2019'])
plt.legend()
plt.show()
echedey-ls commented
Of course. You only had to write import scienceplots
on top of your script and do plt.style.use(...)
before all.
Install it via pip with py -m pip install SciencePlots
Note you won't be able to change colors as you have already forced them with color=...
See Getting started and Using the styles on the wiki.