-4
$\begingroup$

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.

enter image description here

$\endgroup$
7
  • 2
    $\begingroup$ This looks like a Mathematica generated plot. Where did you find it? Can you supply a link? $\endgroup$
    – m_goldberg
    Commented Feb 25, 2013 at 13:30
  • $\begingroup$ I got it from google. $\endgroup$
    – niren
    Commented Feb 25, 2013 at 13:57
  • $\begingroup$ Please post the link anyway. Many students had come in the past with homework plots to be reproduced. Not your case, surely $\endgroup$ Commented Feb 25, 2013 at 14:07
  • $\begingroup$ A hint 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$ Commented Feb 25, 2013 at 14:30
  • $\begingroup$ "I got it from google" - perhaps there's some data on the same page that might be useful... $\endgroup$
    – cormullion
    Commented Feb 25, 2013 at 18:31

3 Answers 3

2
$\begingroup$

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]

fake image

$\endgroup$
4
  • $\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$
    – niren
    Commented Feb 27, 2013 at 6:42
  • $\begingroup$ I have found myself the answer for CDFDeploy problem. I have resolved the problem using Manipulate. $\endgroup$
    – niren
    Commented 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$
    – niren
    Commented 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$
    – cormullion
    Commented Feb 27, 2013 at 11:39
3
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ Thank you for your reply, but Histogram3D doesn't give me the plot the way i want. $\endgroup$
    – niren
    Commented Feb 26, 2013 at 5:54
  • $\begingroup$ What's the problem with Histogram3D? Do you want a gap between the colummns? $\endgroup$
    – fcpenha
    Commented Feb 26, 2013 at 11:42
2
$\begingroup$

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 ]
$\endgroup$
1
  • $\begingroup$ Hello there! I just wanted to point out that you can easily edit your previous answer by clicking the edit link and add this (and other updates) to it instead of serially posting answers :) $\endgroup$
    – rm -rf
    Commented Feb 26, 2013 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.