Plotting a 3 dimensional bar graph in Mathematica involving three axes of data - wolfram-mathematica

So I am fairly new to Mathematica and I have been having trouble finding a way of displaying three dimensional data in a bar structure in Mathematica. However, the best that I can do to represent my data.
My data is formatted in a way that I have a three coordinate structure for all of the points but I want to have each individual point represented. The data is as follows:
{0, 220, 0.05}, {0, 230, 0.33}, {0, 230, 0}, {0, 230, 0},
{0, 250, 1.04}, {0, 250, 0.26}, {0, 250, 1.01}, {0, 250, 4.83}, {0, 250, 0},
{0, 270, 2.69}, {10, 220, 0.6}, {10, 240, 1.28}, {10, 250, 0.97},
{15, 250, 0.25}, {15, 270, 3.52}
How can I make the graph a three dimensional graph with each coordinate point (all three axes) represented in its individual bar on the graph as opposed to a plane?

not sure what you are after -- note ListPlot3D doesn't work really right because some of your points are on top of each other..
Show[{ListPlot3D[data ], Graphics3D[{PointSize[.1], Point[data]}]}]
Show[Graphics3D#{Cuboid[{Append[#[[1 ;; 2]], 0] +
{2, 2, 0}, # - {2, 2, 0}}] & /# data}, Axes -> True,
AxesEdge -> {{-1, -1}, {1, -1}, {-1, -1}},
BoxRatios -> {1, 2, .5}]

ListPointPlot3D[{{0, 220, 0.05}, {0, 230, 0.33}, {0, 230, 0}, {0, 230,
0}, {0, 250, 1.04}, {0, 250, 0.26}, {0, 250, 1.01}, {0, 250,
4.83}, {0, 250, 0}, {0, 270, 2.69}, {10, 220, 0.6}, {10, 240,
1.28}, {10, 250, 0.97}, {15, 250, 0.25}, {15, 270, 3.52}},
Filling -> Bottom, DataRange -> All]
Is this what you want?

Related

Manipulate an image mathematica

I'm having trouble making an image move left to right in mathematica.
I have the manipulate for a point,
(*Rook Movement*)
Manipulate[
Graphics[Translate[Point[{0, 0}], {t, t2}], Axes -> True,
PlotRange -> {{0, 8}, {0, 8}}], {t, 0, 8}, {t2, 0, 8}]
I also have an image defined as "rook".
How do I replace the Point with my image of a rook?
Thanks!
img = ExampleData[{"TestImage", "F16"}];
Manipulate[
Graphics[Inset[img, {t, t2}], Axes -> True,
PlotRange -> {{0, 8}, {0, 8}}], {t, 0, 8}, {t2, 0, 8}]

Draw lines to intersection of two functions

I'm trying to draw lines to the intersection of two functions in Mathematica that can be manipulated with a couple variables each in the following equation:
Manipulate[
Show[
Plot[
Tooltip[QSupply + q^PriceElasticity, "Supply"], {q, 0, 150},
AxesOrigin -> {0, 0},
PlotStyle -> {Thick, Red},
AxesLabel -> {"quantity", "price"},
PlotRange -> {{0, 200}, {0, 200}},
PlotLabel -> Macroeconomy, Ticks -> {{{45, "Qe"}}, {{54.3, "Pe"}}},
BaseStyle -> {FontWeight -> "Bold", FontSize -> 12}
],
Plot[
Tooltip[(DemandElasticity/q) + QDemand, "Aggregate Demand"], {q,
0, 180},
AxesOrigin -> {0, 0},
PlotStyle -> {Thick, Blue}
],
Graphics[{Dashed, Line[{{45, 0}, {45, 54.3}}]}],
Graphics[{Dashed, Line[{{0, 54.3}, {45, 54.3}}]}]
],
{PriceElasticity, 0.6, 10},
{QSupply, -17, 55, 2},
{DemandElasticity, 500, 10000, 100},
{QDemand, 0, 150, 10}
]
I tried using the FindRoot function, but the output doesn't give a raw value (eg. {q->40.0123}. Is there a way to extract the value from the FindRoot output? Or is there a better way to go about this?
I also looked into using Mesh but it looks like that would only help draw a dot at the point of intersection.
Thanks for your help!

Plot, plane, point, line, sphere in same 3D plot. Multiple figures in same plot in Mathematica

How do I plot for example a plane and a line in same 3D plot?
Show and Plot3D can handle it. There are probably many other ways.
l = Line[{{-2, -2, 41}, {6, 4, -10}}];
Show[{Plot3D[{2 x + 7 y}, {x, -2, 5}, {y, -2, 5}, AxesLabel -> {x, y, z}],
Graphics3D[{Thick, l}]}]
I couldn't resist either...
GraphicsGrid[
{
{ContourPlot3D[x + 2 y + 3 z , {x, -2, 2}, {y, -2, 2}, {z, -2, 2},
Contours -> {0}, Axes -> None, ColorFunction -> (White &),
Lighting -> "Neutral"],
Style["One plane", FontFamily -> "Comic Sans MS", 36, Bold]},
{ContourPlot3D[x + 2 y + 3 z , {x, -2, 2}, {y, -2, 2}, {z, -2, 2},
Contours -> {0, 5}, Axes -> None, ColorFunction -> (Green &),
Lighting -> "Neutral"],
Style["Two plane", FontFamily -> "Comic Sans MS", 36, Bold]},
{ContourPlot3D[x + 2 y + 3 z , {x, -2, 2}, {y, -2, 2}, {z, -2, 2},
Contours -> {0}, Axes -> None, ColorFunction -> (Red &),
Lighting -> "Neutral"],
Style["Red plane", FontFamily -> "Comic Sans MS", 36, Bold]},
{Show[
ContourPlot3D[x + 2 y + 3 z , {x, -2, 2}, {y, -2, 2}, {z, -2, 2},
Contours -> {0}, Axes -> None, ColorFunction -> (Blue &),
Lighting -> "Neutral"],
Graphics3D[{Orange, Thickness[0.01],
Line[{{-2, -2, -2}, {2, 2, 2}}]}]
], Style["Blue plane", FontFamily -> "Comic Sans MS", 36, Bold]}
}
]
Just showing off:
Manipulate[
Show[
{Plot3D[ {1}, {x, -1, 1}, {y, -1, 1}, PlotRange -> {-1, 1}, Mesh -> False],
Plot3D[{-1}, {x, -1, 1}, {y, -1, 1}, Mesh -> False],
ParametricPlot3D[{{Sin#t, Cos#t, 1}, {Sin#t, Cos#t, -1}}, {t, 0, 2 Pi}],
Graphics3D[
{Table[{Hue[n/10], Thick, Line[{{Re[#], Im[#], 1}, {-z Re[#], -z Im[#], z}}&#
Exp[n 2 I Pi/10]]}, {n, 10}],
Sphere[{0, 0, 0}, .3]}]}],
{z, 1, -1}]

How can I accelerate a Dynamic showing a graphic with custom ticks?

The following was adapted from a real world code:
ticks = Join[
Table[{i, Style[i, 10, Background -> White], {.04, 0}}, {i, 0, 20,
1}],
Table[{i, Null, {.01, 0}}, {i, 0, 20, 0.1}],
Table[{i, Null, {.025, 0}}, {i, 0, 20, 0.5}]
];
loc = {1, 1};
LocatorPane[
Dynamic[loc, loc[[2]] = #[[2]]; &],
Dynamic#Show[
Graphics[{Dashed,
Line[{{loc[[1]] - 0.5, loc[[2]]}, {0, loc[[2]]}}]}],
ImageSize -> 300, PlotRange -> {{-10, 10}, {0, 20}},
Axes -> {False, True}, AxesOrigin -> {0, 0},
Ticks -> {Automatic, ticks}
]]
The problem I have is that when I use the custom ticks, the updating (moving the locator) becomes much slower than with automatic ticks (Ticks -> {Automatic, Automatic}). How can I avoid what I believe is a ticks rebuilding time?
(I do need the Dynamic#Show[...] for other updating reasons not shown on this code sample).
Just as an example of moving Dynamic inside:
ticks = Join[
Table[{i, Style[i, 10, Background -> White], {.04, 0}}, {i, 0, 20,
1}], Table[{i, Null, {.01, 0}}, {i, 0, 20, 0.1}],
Table[{i, Null, {.025, 0}}, {i, 0, 20, 0.5}]];
loc = {1, 1};
LocatorPane[Dynamic[loc, loc[[2]] = #[[2]]; &],
Show[Graphics[
Dynamic#{Dashed, Line[{{loc[[1]] - 3, loc[[2]]}, {3, loc[[2]]}}]}],
ImageSize -> 300, PlotRange -> {{-10, 10}, {0, 20}},
Axes -> {False, True}, AxesOrigin -> {0, 0},
Ticks -> {Automatic, ticks}]]
Without knowing more about the rest of your program I cannot be very helpful.

Logarithmic Slider Control in Mathematica

I'm making a small interface for calculating voltage dividers in Mathematica. I have two sliders (z1 & z2) that represent the resistor values and a couple of sliders to represent Vin as a sinusoid.
The issue is that the range of available resistor values (in the real world) is roughly logarithmic on {r, 100, 1,000,000}. If I set my slider range to r, however, it's impractical to select common low resistor values in approx. {100, 10,000}.
Is it possible to create a slider that sweeps through a logarithmic range?
Manipulate[
Grid[{{Plot[(VinRCos[t] + VinC), {t, -3, 9},
PlotRange -> {-1, VMax}, AxesLabel -> {t, Vin}]}, {Plot[
z2/(z1 + z2)(VinR*Cos[t] + VinC), {t, -3, 9},
PlotRange -> {-1, VMax}, AxesLabel -> {t, Vout}]}},
ItemSize -> 20],
{{z1, 10000}, 10, 1000000, 10}, {z1}, {{z2, 10000}, 10,
1000000}, {z2}, Delimiter, {{VinR, 2.5}, 0,
5}, {VinR}, {{VinC, 2}, -VMax, VMax}, {VinC}]
Michael's answer is probably the best, i.e. just get the user to specify the exponent. An alternate solution is to make a LogSlider type command. Here's a simple example:
LogSlider[{v:Dynamic[var_], v0_?Positive}, {min_?Positive, max_?Positive},
base_:10, options___] := DynamicModule[{ev}, Dynamic[
var = base^ev;
Slider[Dynamic[ev], Log[base, {min, max}]]]]
LogSlider[v:Dynamic[var_], {min_?Positive, max_?Positive},
base_:10, options___] := LogSlider[{v, min}, {min, max}]
The function only has a subset of the flexibility of Slider and will have to be extended if you want custom step sizes etc...
You then modify your Manipulate by specifying the variables using
{{z1, 10000}, 10, 1000000, LogSlider[##]&} etc...
A simple fix is to just make the slider manipulate the exponent, and plug in e.g. 10^z1 where you need the actual value:
Manipulate[10^z1, {{z1, 5}, 2, 6}] (* 100 to 1M *)
In your particular case, you could of course also input a list of standard resistor values to pick from:
Manipulate[z1, {z1, {100, 110, 120, 130, 150, 160, 180, 200, 220, 240, 270}}]
HTH!
Here is my final result:
Manipulate[
Evaluate[Round[10^Z2]/(Round[10^Z1] + Round[10^Z2])*Vin] "V",
{{Z1, 5}, 2, 6},
Pane["Z1 = " Dynamic[Round[10^Z1] "[CapitalOmega]"],
ImageMargins -> {{2.5, 0}, {3, 0}}],
{{Z2, 5}, 2, 6},
Pane["Z2 = " Dynamic[Round[10^Z2] "[CapitalOmega]"],
ImageMargins -> {{2.5, 0}, {0, -5}}], {{Vin, 2.5}, 0, VMax},
Pane["Vin = " Dynamic[Vin "V"], ImageMargins -> {{0, 0}, {0, -5}}]]
Here is a start to LogSlider that produces the standard two-way behavior the other controls have.
LogSlider[Dynamic[x_], max_] :=
Module[{exp},
Dynamic[exp = Log[max, x];
Slider[Dynamic[exp, (exp = #; x = max^exp) &]]]]
{LogSlider[Dynamic#x, 10^6], Dynamic#x}

Resources