I have a file I import and read into a table of $2 \times n$. I can plot this data using the following code:
directory = "c:\nameofdirectory";
SetDirectory[directory];
filenames = FileNames[];
readlist = ToString[filenames[[1]]];
table = OpenRead[readlist];
data = ReadList[table, {Number, Number}];
Close[table];
ListPlot[data, Frame -> True, PlotRange -> {All, All}, Joined -> True,
FrameLabel -> {"Voltage (V)", "Current (A)"}];
but the $y$-axis is order of $10^{-6} A$. I'd prefer to have my $y$-data scaled by $10^{-6}$ then label my axis is microA
instead of A
. I've tried using Ticks
but I don't really understand how that works (it never changes my plot at all when I use it).
If there's no easy way to do this, can someone tell me how to directly divide my $y$-values from the input? I can separate the $y$-values from "data" and divide them using
xdat = List[];
ydat = List[];
For[j = 1, j < Length[data] + 1, j++,
AppendTo[xdat, data[[j]][[1]]];
AppendTo[ydat, data[[j]][[2]]];
];
y=ydat/10^-6;
but I don't know how to place them back into the form as before so that it can be easily plotted with ListPlot
.
Answer
There are a lot of ways. For example:
data = Table[{x, 10^-6 Sin[x]}, {x, 0, 1, 0.01}];
ListPlot[data /. {x_, y_} :> {x, 10^6 y}, Frame -> True,
PlotRange -> {All, All}, Joined -> True,
FrameLabel -> {"Voltage (V)", "Current (Ma)"}]
Comments
Post a Comment