Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm looking to draw only one half of an axis in ContourPlot3D, mainly because I don't wan't the axis lines to be where the interesting stuff happens (intersection of two surfaces), but I do want to show where the axes are. This is my code so far:

ContourPlot3D[{y == x^2, z == x^3}, {x, -3, 3}, {y, -5, 5}, {z, -10, 10},
   AxesLabel -> Automatic, Boxed -> False, AxesOrigin -> {0, 0, 0},
   Mesh -> None, ContourStyle -> Opacity[0.3]]

This is the result it produces:

enter image description here

I would like only half of each axis to appear on the graph. I already dug through the documentation, but it seems I can only turn the axes on or off completely, no partial option. Thanks in advance for any help.

share|improve this question
    
I think it's not possible if you use the built-in axes. Axes are infinite and always span the complete bounding box. You'll have to draw your own axes. The CustomTicks package will be very helpful in generating your own tick marks. –  Szabolcs Jan 10 at 1:09
    
I believe removing axes altogether and adding your own as Epilog shouldn't be hard. –  caya Jan 10 at 1:54
    
Yes, not easy as a general problem - approachable for a particular case. It depends on how much effort you want to put in your graphic, I believe. OTOH, I haven't checked CustomTicks; if someone has a free solution that fits the bill, go for it :) –  caya Jan 10 at 2:02
    
I'm just throwing it in here because I wonder this myself. In the docs for FullGraphics it says "FullGraphics generates explicit graphics primitives for objects specified by options such as Axes, Ticks, etc." -- is there perhaps a way to extract the primitives used to draw the axes? In that case it should be straightforward to remove half of it. –  Pickett Jan 10 at 2:03
add comment

2 Answers

up vote 2 down vote accepted

Possible workaround with manual dashing

Show[
 ContourPlot3D[{y == x^2, z == x^3}, {x, -3, 3}, {y, -5, 5}, {z, -10, 10},
  Boxed -> False, AxesOrigin -> {0, 0, 0}, Mesh -> None, ContourStyle -> Opacity[0.5], 
  Ticks -> {-Range[3], -Range[5], Range[0, 10, 2]}, 
  AxesStyle -> {Dashing[{0.28, 0.3}], Dashing[{0.3, 0.5}], Dashing[{0, 0.25, 0.5}]}, 
  TicksStyle -> Dashing[{}]],
 Graphics3D[{Text[x, {-3.4, 0, 0}, BaseStyle -> Large], 
  Text[y, {0, -5.5, 0}, BaseStyle -> Large], 
  Text[z, {0, 0, 11.5}, BaseStyle -> Large]}]
]

enter image description here

share|improve this answer
    
Alright, now how could I put labels on those axes (preferably at/near the ends)? –  jlv Jan 10 at 2:34
    
@JimboBimbo You can add Text with explicit positions, see my update. –  ybeltukov Jan 10 at 2:46
    
Ok, that does indeed help. But this solution is odd, because when I rotate the graph, the lengths of the axes seem to change arbitrarily, becoming longer and shorter. I'm not sure if this is a problem with my machine, or something else. They appear in most of the desired side, but shrink and stretch on the other side as I turn it around. –  jlv Jan 10 at 3:02
    
@JimboBimbo Yes, you need to change the dashing parameters for different points of view. It is just a workaround. Strictly speaking you need a package like CustomTicks as Szabolcs wrote in comments. –  ybeltukov Jan 10 at 3:07
add comment

It is not by chance that ContourPlot3D defaults to Boxed->True. It leaves the surfaces away from the axes.

You can then add other axes or wherever you like. Below, the x and y axes are projected onto the x y plane. I find this a bit helpful for conveying that (0,0,0) is somewhere in the center of the box.

Show[ContourPlot3D[{y == x^2, z == x^3}, {x, -3, 3}, {y, -5, 
   5}, {z, -10, 10},
  BaseStyle -> 16, BoxStyle -> Directive[Dashed, GrayLevel[.25]], 
  AxesLabel -> Automatic,
  Mesh -> None, ContourStyle -> Opacity[0.3]],
 Graphics3D[{Thickness[.005], Dashed, Blue, 
   Line[{{-3, 0, -10}, {5, 0, -10}}], 
   Line[{{0, -5, -10}, {0, 5, -10}}]}]]

enter image description here

share|improve this answer
    
Ok, but is it possible to add ticks and numbers to those lines so they look like axes? –  jlv Jan 10 at 2:15
    
You can easily add ticks and numbers using Table. –  David Carraher Jan 10 at 3:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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