0

I want to plot a 3d bar chart or histogram with python (or scatter ..), and rappresent the color of each bar according to a matrix.

The heightness of each bar is in the matrix "z". The color of each single bar should change according to the numeric matrix "colors" (because i have 4d data)

I haven't found anything in the examples with my type of data

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

x_axis = ["Piccola",
          "Media",
          "Grande"]

y_axis = [1,0.9,0.8,0.7,0.6,0.5,0.4,0.3,0.2,0.1]

z = [ [0.03,0.18,0.24,0.12,0.9,0.21,0.06,0.24,-0.06,-0.24],
      [0,0.03,0.03,-0.06,0.03,0,-0.03,-0.03,-0.09,-0.09],
      [0,0,-0.03,-0.03,-0.06,-0.06,-0.03,-0.06,-0.09,-0.29] ] 

colors =[ [24.67,27.50,30.25,25.6,31.87,42.67,31.39,49.58,50.27,53.76],
          [17.17,21.67,21.96,22.11,19.45,17.44,17.95,22.51,28.21,46.14],
          [17.18,18.01,17.68,15.03,17.80,17.93,14.75,18.88,24.7,39.75] ]
roy
  • 35
  • 1
  • 1
  • 4
  • Possible duplicate of [Formatting a 3d bar plot in matplot lib](https://stackoverflow.com/questions/31810776/formatting-a-3d-bar-plot-in-matplot-lib) – pangyuteng Sep 09 '19 at 14:38
  • Thanks, but it's different since i want to color each bar with another matrix of numerica data, i don't want to set a default color – roy Sep 09 '19 at 15:12
  • The idea is the same. Just, instead of color strings like ["r", "g", "y"] you will need to run your values through a colormap (`cmap(norm(colors))`). – ImportanceOfBeingErnest Sep 09 '19 at 15:43

0 Answers0