# Help with plotting in Mathematica

• Mathematica
• Gili
In summary, Gili was looking for help with plotting an intersection of three cylinders. She was told that she should use Mathematica, but she is not too familiar with all the options there. She was also told that she should use the Graphics3D function, but this did not work. Finally, she was advised to treat the cylinders as solids and to use RegionPlot3D to generate a sphere-like plot.
Gili
Hello,
I could use some help with plotting.
I need to plot the intersection of three cylinders:
x^2+y^2=1
z^2+x^2=1
y^2+z^2=1

it's really hard to visualize how this shape looks like, and I need to plot it.
I was told that I should use Mathematica, but I'm not too familiar with all the options there...

can anyone help me?
thanks,
Gili

Gili said:
Hello,
I could use some help with plotting.
I need to plot the intersection of three cylinders:
x^2+y^2=1
z^2+x^2=1
y^2+z^2=1

it's really hard to visualize how this shape looks like, and I need to plot it.
I was told that I should use Mathematica, but I'm not too familiar with all the options there...

can anyone help me?
thanks,
Gili

I will be more specific: I need to plot the faces of the set:
{ (x,y,z): x^2+y^2<=1 and z^2+x^2<=1 and y^2+z^2<=1 }

these three shapes on the same graph would look like 3 circles with their centres at the origin on 3 differend planes. we'll start with x^2+y^2=1. this is your normal 2d circle. then super imposed on this is z^2+x^2=1, this is the same shape except it is rotated around the x axis. y^2+z^2=1 is similar to this except it is rotated around the Y axis. I am pretty sure that is right but I am not guaranteeing anything. you should end up with something resembling a very crude wire frame of a sphere hope it helped a bit.

PS the radius of these circles is 1. (i think)

Alistair said:
these three shapes on the same graph would look like 3 circles with their centres at the origin on 3 differend planes. we'll start with x^2+y^2=1. this is your normal 2d circle. then super imposed on this is z^2+x^2=1, this is the same shape except it is rotated around the x axis. y^2+z^2=1 is similar to this except it is rotated around the Y axis. I am pretty sure that is right but I am not guaranteeing anything. hope it helped a bit.

PS the radius of these circles is 1. (i think)

Hi, I need a three dimensional plot..

hmmmm. sorry can't help you there. i don't know af any programs that would allow you to do that. sorry. try posting this in the mathematics forum. Auto Cad might be able to help get the picture.

Do you need to plot, just because you're having a hard time visualizing it? Or is plotting it actually part of the assignment?

You can certainly write a program in Mathematica to display such a thing, but I don't think it would be easy, at all.

You may want to look at the Graphics3D function, which can render arbitrary 3D shapes. See section 2.10.8 of the Mathematica Book from within Mathematica's Help window. Unfortunately, I don't see any cylinder primitives, but you might be able to make something decent out of it.

- Warren

chroot said:
Do you need to plot, just because you're having a hard time visualizing it? Or is plotting it actually part of the assignment?

You can certainly write a program in Mathematica to display such a thing, but I don't think it would be easy, at all.

You may want to look at the Graphics3D function, which can render arbitrary 3D shapes. See section 2.10.8 of the Mathematica Book from within Mathematica's Help window. Unfortunately, I don't see any cylinder primitives, but you might be able to make something decent out of it.

- Warren

tried that...
I still don't know how to do it...
anyone?

Try using :

Show[Graphics3D[shape]]

A possible shape is a cylinder, in the form:

Cylinder[r, h, n]

where r is the radius, h the height, and n the number of polygons used to draw it.

Cylinder is a 2D, not 3D, graphics primitive. That won't work, unfortunately.

- Warren

chroot said:

Cylinder is a 2D, not 3D, graphics primitive. That won't work, unfortunately.

- Warren

Uhh, too bad. Hadn't had the time to try it out right now.

Btw, tried it out, worked just fine. Can draw sets of cylinders with parallel axis only, though, which doesn't help Gili, unfortunately.

Edit: this should be more useful:http://forums.wolfram.com/mathgroup/archive/2001/Dec/msg00287.html" .

Last edited by a moderator:
It looks like you would have to use ParametricPlot for this. I'd have to play around with setting all three equations equal to each other to actually plot the intersection.

Time to dig up an old thread. I just got Mathematica and I've been trying to learn it using Google. This was one of the first results. So for the benefit of other searchers, I'll post the answer I found.

First, treating the cylinders as hollow shells (x^2+y^2=1 vs x^2+y^2<1) yields 8 points. Not very interesting.
Code:
Solve[x^2 + y^2 == 1 && x^2 + z^2 == 1 && y^2 + z^2 == 1, {x, y, z}]

If you treat them as solids, you get a cool sphere-like thing.
Code:
RegionPlot3D[
x^2 + y^2 <= 1 && x^2 + z^2 <= 1 && y^2 + z^2 <= 1,
{x, -1, 1}, {y, -1, 1}, {z, -1, 1}, PlotPoints -> 80, Mesh -> None]

Nialsh I love you

## 1. How do I plot a function in Mathematica?

To plot a function in Mathematica, you can use the Plot function. This function takes in the function you want to plot and the range of values you want to plot it over. For example, to plot the function f(x)=x^2 from x=0 to x=5, you would use the command Plot[x^2, {x, 0, 5}]. This will generate a plot of the function.

## 2. How do I customize the appearance of my plot?

To customize the appearance of your plot, you can use various options in the Plot function. Some common options include changing the color, style, and thickness of the plot line, adding labels and titles, and adjusting the range of the axes. You can also use the PlotStyle option to specify a specific color or style for your plot. For example, Plot[x^2, {x, 0, 5}, PlotStyle -> Red] will plot the function in red.

## 3. How do I plot multiple functions on the same plot?

To plot multiple functions on the same plot, you can use the Plot function multiple times, each time specifying a different function. Alternatively, you can use the Plot function with a list of functions as the first argument. For example, Plot[{x^2, x^3}, {x, 0, 5}] will plot both f(x)=x^2 and g(x)=x^3 on the same plot.

## 4. How do I add a legend to my plot?

To add a legend to your plot, you can use the PlotLegends option in the Plot function. This option takes in a list of labels for each function in the plot. For example, Plot[{x^2, x^3}, {x, 0, 5}, PlotLegends -> {"f(x)", "g(x)"}] will add a legend with labels "f(x)" and "g(x)" to the plot.

## 5. How do I save my plot as an image file?

To save your plot as an image file, you can use the Export function. This function takes in the plot object and the desired file format (e.g. PNG, JPEG, PDF) as arguments. For example, Export["plot.png", Plot[x^2, {x, 0, 5}]] will save the plot as a PNG file named "plot.png". You can also specify the file path and other options in the Export function.

• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
234
• MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
743
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
391
• MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K