有很多方法可以在条形图中将产品标签下移:
# import libraries
import pandas as pd
import holoviews as hv
import hvplot
import hvplot.pandas
# create example dataframe
df = pd.DataFrame({
'product': ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'],
'month': ['201801', '201802', '201803', '201801', '201802', '201803', '201801', '201802', '201803'],
'volume': [100, 125, 110, 85, 87, 96, 177, 167, 130]
})
可能的解决方案:
# create barplot option 1
df.hvplot.bar(x=['product', 'month'], y='volume')
# or do it like this
df.hvplot.bar(x='product', y='volume', by='month')
# or create your barplot like this
hv.Dataset(df).to.bars(['product', 'month'], 'volume')
这将导致以下情节: