4

I have found code to make bar charts and pie charts in plotly also other 3D plots. A simple bar chart works like this:

from  plotly.offline import plot
from plotly.graph_objs import *
trace1 = Bar(
    x=['cats', 'dogs', 'monkeys'],
    y=[20, 14, 23]
)
data = Data([trace1])
plot(data)

Is there any option available in plotly to plot this bar graph in 3D layout. Also for pie chart/donut also?

Naima
  • 101
  • 1
  • 4
  • 9
  • There is no real function in Plotly to do barchart3d and I was really disappointed by the look of 3D filled lines so I tried to create a function to create some nice looking easily. It's bind with a panda series but it's quite easy to convert a list to panda series. Here is the project : https://github.com/AymericFerreira/Plotly_barchart3D – Feitan Jun 17 '20 at 00:13

2 Answers2

3

Have a look at the official documentation: https://plot.ly/python/3d-charts/

As this should be a list of all available 3D Charts in plot.ly:

No, it seems there is currently no option for 3D Bar/Pie/Donut.

See also: https://community.plot.ly/t/will-there-be-3d-bar-charts-in-the-future/1045/2

Bar/Pie/Donut are two-dimensional by nature, making them 3D would provide no additional value (apart from cosmetics)

As suggested in the link above, you could try using 3D filled line plots.

Though I doubt that the additional complexity required to get the desired result is worth it.

Sebastian Loehner
  • 1,302
  • 7
  • 5
1

Still, 3D bar charts haven't been implemented in Plotly. There is a variant of 3D bar chart plotting function at https://github.com/buran21/barchart3d-plotly, intended for drawing of 1D labelled data. An example:

import plotly.data as pdata
from barchart3d import barchart3d

df = pdata.gapminder()
df = df[df['year'] == 2007].sort_values(by='pop', ascending=False).head(10)
fig = barchart3d(
    df['country'].to_list(), (df['pop']/1e06).round(1).to_list(),
    'Top 10 most populous countries in 2007 [Gapminder]', 'Population, mln',
    colorscale='Bluered', opacity=0.6, flatshading=True)
fig.show()

Example output

Serge Tochilov
  • 191
  • 2
  • 4