How can I draw a plot like this one? I want to be able to specify the x-axis, y-axis, and z-axis ticks and the number of bars in the plot.
3 Answers
Since the Google reference isn't forthcoming, it's probably easier to fake it like this:
i = Blur[
Image[Graphics[{
Black,
Table[Rectangle[{x, y}, 20 + {x, y}],
{x, 0, 100, 35},
{y, 0, 100, 35}]},
PlotRangePadding -> 15,
Background -> White],
ImageSize -> 100],
1];
xticks = Transpose[{Range[0, 100, 20], Range[0, 1000, 200]}];
yticks = Transpose[{Range[0, 100, 20], Range[0, 1000, 200]}];
zticks = Transpose[{Range[0, 1, .2], Range[0, 25, 5]}];
ListPlot3D[ImageData[i] /. {x_, y_, z_} -> 1 - z,
Mesh -> 20,
Ticks -> {xticks, yticks, zticks},
PlotRangePadding -> 0.1]
-
$\begingroup$ Thank you for your answer. I got another problem not only with this Plot, its with all the try that i made for the same plot. When i Deploy the code in CDFDeploy, its working fine but i couldn't rotate the plot. $\endgroup$– nirenCommented Feb 27, 2013 at 6:42
-
$\begingroup$ I have found myself the answer for CDFDeploy problem. I have resolved the problem using Manipulate. $\endgroup$– nirenCommented Feb 27, 2013 at 11:05
-
$\begingroup$ I have customized the number of bars i want on the plot, But i couldn't customize the height of each bar, Because in your code you get the data from image which range between 0 and 1. I want the height of some bar to be 20 and some to be 25 and so on. $\endgroup$– nirenCommented Feb 27, 2013 at 11:20
-
4$\begingroup$ @niren I think you should probably first of all specify/supply the 'data' that you want to plot, then people here on this site can help you plot it in different ways. I just used an image because there was no data. To change the heights of the bars in my example, I would make some of the squares less black ...:) Perhaps you really want to construct a 3D object from
Cuboids
? If you put more effort into your question, any answers you get will be more relevant and useful to you. $\endgroup$ Commented Feb 27, 2013 at 11:39
You could do something similar to the given example using Histogram3D, which comes with many options.
You need to specify the data you have in hand in your question. If you really need a flat top, as you show in your example, you could use the function UniformDistribution
as the input for Histogram3D
.
You really need to specify better what you want. In case you want to draw 3D rectangular columns with some gap in between, the following code would do the work:
max = 10;
step = max;
factor = 2*max;
DiscretePlot3D[ factor * PDF[
UniformDistribution[{-max, max}], {x, y} ],
{x, -max, max, step}, {y,-max, max, step},
ExtentSize -> max/2 ]
f[x_, y_, n_] := Total@Flatten@ Table[UnitBox[(x - a)/100, (y - b)/100], {a, 200, n 200, 200}, {b, 200, n 200, 200}];
$\endgroup$