Message Boards Message Boards

0
|
3123 Views
|
4 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Plot a ListLinePlot with time stamps?

Posted 5 years ago

enter image description here

I have the following command:

ListLinePlot[Transpose[sampleData[[{2, 18}]]], Frame -> True, 
 PlotRange -> {All, {0, 5000}}, 
 FrameLabel -> {"Latitude (\[Degree])", 
   "\!\(\*SubscriptBox[\(T\), \(e\)]\) (K)"}]

If I want to get the timestamp, which corresponds to sampleData[{1}] for Latitude >40 and Latitude <80, how should the command be rewritten?

I tried,

ListLinePlot[Transpose[sampleData[[{2, 18}]] /; sampleData[[2]] >= 40 && sampleData[[2]] <= 80], Frame -> True, 
PlotRange -> {All, {0, 5000}}, 
FrameLabel -> {"Latitude (\[Degree])", 
"\!\(\*SubscriptBox[\(T\), \(e\)]\) (K)"}]

but it doesn't work.

Thanks

POSTED BY: T P
4 Replies
Posted 5 years ago

enter image description here

Hi Rohit,

Transpose[sampleData[[{1, 2, 15}]]]

{{2014, 11, 1, 1, 1, 0.696}, 21.1056, 248160.}, {{2014, 11, 1, 1, 1, 1.197}, 21.0738, 249216.},..............................

  • Index 1 refers to the timestamp which I must retrieve,
  • index 2 is the x-axis variable which I must retrieve from # >= 40 && # <= 80 & I
  • will also need data from Index 15 and 18

How can I retrieve a list of these data points?

POSTED BY: T P
Posted 5 years ago

If your data looks like this

data = {{{2014, 11, 1, 1, 1, 0.696}, 21.1056, 248160.}, 
        {{2014, 11, 1, 1, 1, 1.197}, 41.0738, 249216.},
        {{2014, 11, 1, 1, 1, 2.197}, 60.0738, 249216.}}

Then this will give the elements where the second index (x value) is in the desired range

Select[data, #[[2]] >= 40 && #[[2]] <= 80 &]
(* {{{2014, 11, 1, 1, 1, 1.197}, 41.0738, 249216.}, {{2014, 11, 1, 1, 1, 2.197}, 60.0738, 249216.}} *)

To get just the timestamp and x value

Most /@ Select[data, #[[2]] >= 40 && #[[2]] <= 80 &]
(* {{{2014, 11, 1, 1, 1, 1.197}, 41.0738}, {{2014, 11, 1, 1, 1, 2.197}, 60.0738}} *)
POSTED BY: Rohit Namjoshi
Posted 5 years ago

Hi Rohit, this worked.

POSTED BY: T P
Posted 5 years ago

What you mean by "get the timestamp" is not at all clear. Please describe the structure of sampleData with some concrete examples. If all you want to do is filter the data that is plotted then you can use Select.

data = Range[100];
Select[data, # >= 40 && # <= 80 &]
(* {40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80} *)

Or if you have to use a pattern then

data /. x_ /; (x < 40 || x > 80) -> Nothing
POSTED BY: Rohit Namjoshi
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