I have a simple 3d histogram

which I want to import into pgfplots, e.g. using matlab2tikz or by hand.
PGFplots does not offer 3d histograms.
Is there an easy way to do this?
|
You can use If you have saved a plot from Matlab as an image called
will generate
For this, you need to provide the mapping from the data coordinate system to the figure coordinate system for four points. You can do this by finding the data coordinates for the points using the "Data Cursor" in Matlab, and finding the figure coordinates (in I've written a Matlab script called Here's an example of how I arrived at the above figure.
|
|||||||||||||
|
|
I managed to achieve a 3-dimensional histogram effect by repeating the coordinates. I just repeat each x,y combination 4 times, once for each of the 4 possible bar tops it could appear in. For example, the code
produces
The 0 z-coordinate values above are meant to have the same value as I don't know how to make the colour of the sides of the bars the same as the top, hence the monochrome colormap. A larger example can be seen here
This is from some data I produced in python. To save it to a file, I had to add a few for loops that make sure all the points at the border are set to have z value equal to zmin. The function below takes the x, y mesh stored in
So for example
produces the simple plot above, this time with a grid on the z plane as none of the points are skipped. |
|||||||||||
|
|
matlab2tikz, at least in its latest dev version, pretty much supports this already (save for the colors it seems). This
gives
|
|||||||||||
|
pgfplotsoffer. – percusse Apr 23 '12 at 14:14NaNvalues. – percusse Apr 24 '12 at 0:20