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 have multiple plots of permittivity against frequency, but they're hard to read because the frequency labels go from 4x10^14 to 1x10^15 in Hz. I want to label the frequency with THz instead of Hz, so each value would just get divided by 10^12. How do I do this?

share|improve this question

3 Answers 3

In Mathematica everything is an expression. That's the overarching concept that is fully pervasive throughout the entire Mathematica system. If you look at your plot expression with FullForm, you should be able to find your axes labels and tick marks and data. Then extract those expressions with pattern matching and modify. Then re-Evaluate.

I can't write you code, because I don't know how your particular Plot expressions look like. I think this necessarily has to be a mostly textual answer.

share|improve this answer

Get the tick specs using AbsoluteOptions and modify them as you like as follows:

lp = ListPlot[RandomReal[{0, 1}, {10}], Joined -> True,  
DataRange -> {10^10, 10^14}, Frame -> True];
fts = FrameTicks /. AbsoluteOptions[lp, FrameTicks];
fts[[1]] = ReplaceAll[#, {tick_, lbl_, {pos__}, {style__}} :> {tick, 
   If[lbl == "", "", ToString[tick/(10^12)] ~~ "THz"], {pos}, {style}}] &@fts[[1]];
lp
ListPlot[RandomReal[{0, 1}, {10}], Joined -> True, 
DataRange -> {10^10, 10^14}, Frame -> True, FrameTicks -> fts]

enter image description here enter image description here

share|improve this answer

The easiest thing is often to scale the data itself rather than mess around with custom labels for the ticks. For example:

f[x_] := Log[x]

(* unscaled plot *)
Plot[f[x], {x, 4*10^14, 10^15}]

(* scaled plot *)
Plot[f[10^12 x], {x, 400, 1000}]

Or if you are plotting numerical data:

data = Table[{x, Log[x]}, {x, 4*10^14, 10^15, 10^13}];

(* unscaled plot *)
ListPlot[data]

(* scaled plot *)
ListPlot[{10^-12, 1} # & /@ data]
share|improve this answer
    
I don't think this answers the question. The o/p clearly indicated that the Plots already exist, because the frequency labels are "hard to read". Of course, rescaling the data itself that was used to generate the Plots would be best, but that's not possible here. The o/p already has the Plots. I'd almost down-vote. –  Andreas Lauschke Jul 5 '12 at 22:20
2  
@AndreasLauschke I'd disagree that this doesn't answer the question. Specifically, it tries to circumvent the problem prior to plot generation. Unless the plot requires a lot of time to generate (which the op does not state), then this is a perfectly workable solution. –  rcollyer Jul 5 '12 at 22:44
    
@rcollyer: The o/p clearly says "they're hard to read because the frequency labels go ...". And you're wrong with "it tries to circumvent". There is no active attempt made by the o/p or me. "To try" and "to circumvent" are active tasks, actively pursued. If someone starts out with a certain situation and tries to cope, that's not a matter of trying to circumvent the problem that presented the problem in the first place. That's like saying "when someone asks how to clean up after a bomb exploded, it would have been better to prevent the bomb from exploding". Nice! Downvoting. –  Andreas Lauschke Jul 5 '12 at 22:51
3  
@AndreasLauschke again, I disagree. "Hard to read" does not equate with difficult to generate without that information, then Simon's solutions is perfectly serviceable. A difficult to generate plot would, of course, require a slightly different solution especially if the goal was to effect the rescaling without regenerating the plot. Again, that goal is not specified. The OP simply states that he has a plot and because of the large numbers used, it is difficult to read, and do we know how to rescale it! –  rcollyer Jul 5 '12 at 22:59
3  
@AndreasLauschke, to me the question didn't necessarily imply that the plots would be hard to recreate. It's not stated explicitly so it's open to interpretation. I agree that my answer is very basic, and I wasn't sure whether to post a comment or an answer. But I have seen several questions on this site where the "trivial and obvious" answer is mentioned in a comment, which then turns out to be exactly what the OP was looking for. –  Simon Woods Jul 6 '12 at 8:55

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.