2
$\begingroup$

I have a text file data1 (not comma separated) that consists of a huge number of numbers, it's basically a matrix of numbers. I would like to have a smooth code to e.g. plot columns $a$ to $b$ but only between rows $c$ and $d$. The following ugly ass code works for the special case of plotting the full columns

ListLogLinearPlot[{data1[[All, {1, 3}]], data1[[All, {1, 4}]], 
  data1[[All, {1, 5}]], data1[[All, {1, 6}]], data1[[All, {1, 7}]], 
  data1[[All, {1, 8}]], data1[[All, {1, 9}]], data1[[All, {1, 10}]]},

As can be seen I have put in manually instead of a nice code. Also I suspect one could change All to something that only takes row $c$ to $d$. Is this possible and if so what is a nice code for that?

$\endgroup$
1
  • $\begingroup$ Have you looked into the syntax data[[a;;b,c;;d]], et c.? This lets you pull parts a through b of the top level, c through d of the second level, and so on. $\endgroup$ Sep 14 '16 at 18:05
2
$\begingroup$

Generate some matrix:

data = RandomReal[1, {10, 10}]

Then, to take e.g. rows from 2 to 4, and columns from 7 to 9, use Span:

subdata = data[[2 ;; 4, 7 ;; 9]]

{{0.29785, 0.186604, 0.0372086}, {0.222346, 0.578416, 0.1889}, {0.346148, 0.731862, 0.889276}}

ListLogLinearPlot[subdata, Frame -> True, PlotStyle -> PointSize[Large]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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