Message Boards Message Boards

0
|
13427 Views
|
5 Replies
|
2 Total Likes
View groups...
Share
Share this post:

3D Plot with logarithmic x and y axes

Posted 11 years ago
Hey there!

I want to achieve a 3D plot, with the x and y axes being logarithmic.

The function to be plotted is f(x,y) = (x - y)/(1 + x*y)  and
x should range from log(-3, 3) --> 0.001 to 1000 and the same for y.
In the function is a steep inclination that i want to see more clearly.

I already looked into

http://mathematica.stackexchange.com/questions/34460/plot3d-with-a-log-scale-only-along-the-y-axis
trying the proposed logf[logx_, logy_] := Log10[(x - y)/(1 + x*y)]

Plot3D[(x - y)/(1 + x*y), {x, Log[10, -3], Log[10, 3]}, {y, Log[10, -3],   Log[10, 3]}]
which was interpreted in another way by mathematica
(and probably would have led to an axis range of .001 to 1000 in linear steps, anyway)

I also read somewhere about the LevelScheme package, but as a beginner to mathematica I am a bit hesitant to start with the heavy stuff. ;)

So, is there some kind of LogLogPlot3D? ;) Or what syntax would i need to use to achieve logarithmic x and y axes in a 3D plot?
I am sure, there is a simple solution that i overlooked

Best Regards!
POSTED BY: Steffi Kuehn
5 Replies
Hello Steffi,
I am glad that this was useful. Your english is fine.

One of the difficult things about answering questions in this community is that the answer should be useful for a wide range of readers: simple answers for advanced users can be insulting; complicated answers for beginners are useless.  My guess is that you are someplace in the spectrum.

I usually try to include a number of steps to lead the reader to a solution. This morning I was in a hurry and didn't....

So, here are different ways to do the same thing. As you can see, some are more readable than others; but having examples to study is useful, I think.  I would advise to evaluate these lines  one at a time instead of one big cell full of code.
 tickPositions = FindDivisions[{Log[10, .001], Log[10, 1000]}, 8]
 tickLabels = 10^tickPositions
 
 tickStructure =  Table[{tickPositions[[i]], tickLabels[[i]]}, {i, 1, Length[tickPositions]}]
 
 tickStructure = Transpose[{tickPositions, tickLabels}]
 
 tickStructure =
  Map[{#, 10^#} &, FindDivisions[{Log[10, .001], Log[10, 1000]}, 8]]

tickStructure =
Thread[({#, 10^#} &)[
   FindDivisions[{Log[10, .001], Log[10, 1000]}, 8]]]


Finally, looking at this with the names and refering to Details in Ticks in the help browser will help you see what is going on.
Plot3D[(10^x - 10^y)/(1 + 10^x*10^y), {x, Log[10, .001],
  Log[10, 1000]}, {y, Log[10, .001], Log[10, 1000]},
PlotRange -> All,
  Ticks -> {
   tickStructure,
   tickStructure,
   Automatic} ]

My general advice when you see code posted here that is mysterious is to work from the inside out. Copy what Ticks is pointing to, evaluate it, and then look and see what kind of structure that Ticks is looking for.

I hope this helps.

Kind regards, Craig
POSTED BY: W. Craig Carter
Posted 11 years ago
Dear Craig,
that is what I was looking for, thanks a lot!

If it is not too much, could you shortly point out, which cue or catchword I could look into to understand the usage of N@10^FindDivision or Ticks* (I am no native speaker. The word Ticks does refer to the numbers on the axis, doesn't it?) to avoid the same questions next time? And what Matrix is there that needs to be transposed?

Best Regards
Steffi

*something along that line http://support.wolfram.com/kb/5576 just a bit more basic
POSTED BY: Steffi Kuehn
Posted 11 years ago
Dear Craig, thanks a lot for your effort!
It's not quite what I am looking for, but the idea to directly use the 10^x  was something I somehow completely overlooked and therefore a really valuable hint!

Even though, as you probably saw for yourself, the code looks like the attached file. 
But I want the X and Y axis to have a range from 10^(-3) to 10^3 instead of -3 to 3.
I would have expected it to work that way with the following

Plot3D[(10^x - 10^y)/(1 + 10^x*10^y), {x, -3, 3}, {y, -3, 3}, PlotRange -> All]

as we now have the values 10^(-3) = .001 to 10^3 =1000 for X and Y  .... but the axis still range from -3 to 3.

This kinda makes sense, as the plot would be able to show very small values like .001 but the x values themself (in opposite to ten to the power of x) don't range up to 1000, so there would be no chance to plot it on the x axis.
Therefore, the 10^x and 10^y  (=.001 to 1000) would need to be the plotted axis parameter instead of x and y (= -3 to 3). 
Do you perchance also have an idea how to achieve that?

Thanks in advance!
Attachments:
POSTED BY: Steffi Kuehn
How about this?
 Plot3D[(10^x - 10^y)/(1 + 10^x*10^y), {x, Log[10, .001],
   Log[10, 1000]}, {y, Log[10, .001], Log[10, 1000]},
  PlotRange -> All,
   Ticks -> {
     Transpose[{FindDivisions[{Log[10, .001], Log[10, 1000]}, 8],
      10^FindDivisions[{Log[10, .001], Log[10, 1000]}, 8]}],
    Transpose[{FindDivisions[{Log[10, .001], Log[10, 1000]}, 6],
      10^FindDivisions[{Log[10, .001], Log[10, 1000]}, 6]}],
    Automatic
   }
  ]



Plot3D[(10^x - 10^y)/(1 + 10^x*10^y), {x, Log[10, .001],
  Log[10, 1000]}, {y, Log[10, .001], Log[10, 1000]},
PlotRange -> All,
  Ticks -> {
    Transpose[{FindDivisions[{Log[10, .001], Log[10, 1000]}, 8],
     N@10^FindDivisions[{Log[10, .001], Log[10, 1000]}, 8]}],
   Transpose[{FindDivisions[{Log[10, .001], Log[10, 1000]}, 6],
     N@10^FindDivisions[{Log[10, .001], Log[10, 1000]}, 6]}],
   Automatic
   }
  ]
POSTED BY: W. Craig Carter
Something like this?
 Plot3D[(10^x - 10^y)/(1 + 10^x*10^y), {x, Log[10, .001],
   Log[10, 1000]}, {y, Log[10, .001], Log[10, 1000]},
  PlotRange -> All,
   Ticks -> {
     FindDivisions[{Log[10, .001], Log[10, 1000]}, 8],
    FindDivisions[{Log[10, .001], Log[10, 1000]}, 8],
    Automatic
    }
   ]
POSTED BY: W. Craig Carter
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract