2016-05-04 25 views
6

Gruplandırılmış (barmode = 'grup') çubuk grafik alt çizimlerini plot olarak oluşturmak istiyorum. Şimdi sorun, komploların izler olarak çubuk grafikler oluşturmamasıdır. Bunun yerine, gruplandırılmış çubuk grafikler Çubuk izlerinin listeleri olarak oluşturulur. Bu nedenle, alt piksel olarak gruplandırılmış çubuk grafikler içeren bir şekil nasıl oluşturacağımı bilmiyorum (yani figure.append_trace() kullanarak gruplandırılmış bir çubuk grafik ekleyin).Grup çubuk grafiklerini plotly olarak alt piksel olarak ekleme

Örneğin

, nasıl this sample oluşturulan çubuk grafikler kullanarak subplots oluşturabilirsiniz:

import plotly.plotly as py 
import plotly.graph_objs as go 
trace1 = go.Bar(
    x=['giraffes', 'orangutans', 'monkeys'], 
    y=[20, 14, 23], 
    name='SF Zoo' 
) 
trace2 = go.Bar(
    x=['giraffes', 'orangutans', 'monkeys'], 
    y=[12, 18, 29], 
    name='LA Zoo' 
) 
data = [trace1, trace2] 
layout = go.Layout(
    barmode='group' 
) 
fig = go.Figure(data=data, layout=layout) 
plot_url = py.plot(fig, filename='grouped-bar') 
+0

daha spesifik olabilir? – wind85

+0

Özet olarak matplotlib kullanarak çözümlere açık olacak mısınız? – user2027202827

+0

@hobenkr evet bu iyi olurdu –

cevap

0

Ben plotly paketi ama ne görünüyor sonra olan matplotlib kullanarak oldukça basittir hiç kullanmadım. Alt grup olarak gruplandırılmış çubuk grafiklerini göstermenin oldukça minimal bir örneği. Sorduğun şey tam olarak bu değilse bana haber ver.

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() 

Matplotlib plot

1

EVET! Plot.ly Yeni ve bu sorunu vardı ve benim yorumunda belirtildiği gibi, ben sadece çeşitli nedenlerle pandas/matplotlib içinde yapamadık. Ancak altbölümlerin büyüsüyle, aslında çoklu parçaları bir araya getirerek bunları bir araya getirebilirsiniz. enter image description here

import plotly.plotly as py 
import plotly.graph_objs as go 
trace1 = Bar(
    x=['giraffes', 'orangutans', 'monkeys'], 
    y=[20, 14, 23], 
    name='SF Zoo' 
) 
trace2 = Bar(
    x=['giraffes', 'orangutans', 'monkeys'], 
    y=[12, 18, 29], 
    name='LA Zoo' 
) 
trace3 = Scatter(
    x=['giraffes', 'orangutans', 'monkeys'] 
    ,y=[33,20,17] 
    ,name='subplots ftw' 
) 


fig = tools.make_subplots(rows=2, cols=1, shared_xaxes=True) 

fig.append_trace(trace3, 1,1) 
fig.append_trace(trace1, 2, 1) 
fig.append_trace(trace2,2,1) 


fig['layout'].update(height=600, width=600) 
iplot(fig) 
İlgili konular