擅长:python、mysql、java
<p>我从来没有使用过plotly包,但是使用matplotlib似乎很简单。下面是一个将分组条形图显示为子图的非常小的示例。如果这不是你想要的,请告诉我。在</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
# First subplot
plt.subplot(2, 1, 1)
x = np.linspace(0, 10)
y = np.sin(np.pi * x)
plt.plot(x, y)
# Second subplot
plt.subplot(2, 1, 2)
titles = ('Canada', 'US', 'England', 'Other')
y_pos = np.arange(len(titles))
width = 0.2
bar_height1 = [6,5,7,2]
bar_height2 = [x+1 for x in bar_height1]
plt.bar(y_pos, bar_height1, width, align='center', alpha=0.8, color='r')
plt.bar(y_pos+width, bar_height2, width, align='center', alpha=0.8, color='b')
plt.xticks(y_pos + width/2, titles)
# Show the plots
plt.show()
</code></pre>
<p><a href="https://i.stack.imgur.com/hZmuV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hZmuV.png" alt="Matplotlib plot"/></a></p>