0
$\begingroup$

I have loaded data from a CSV file which i want to plot in a BarChart but i only wish to plot 0:100 instead of the entire dataset. Is there a way to set a range for the data?

So far i am just plotting everything:

data = Import["/Users/matek/NetworkTest/without_use_in_and_out.csv", "Table"]

Show[
    BarChart[data, ChartLegends -> {"TX", "RX"}],
    ImageSize -> 600
]

data:

{{1,2},{3,4},{5,6},...}
$\endgroup$
8
  • $\begingroup$ How about PlotRange? $\endgroup$ Commented Jul 6, 2013 at 13:46
  • $\begingroup$ @TeakeNutma, my dataset is very big and it would be more suiteable if i could reduce it so the plotting is executed much faster. Else i need to manually manipulate the file, which is quite tedious. $\endgroup$
    – JavaCake
    Commented Jul 6, 2013 at 13:50
  • $\begingroup$ Ok, assuming your dataset is of the form data = {{tx_1, ..., tx_n}, {rx_1, ...., rx_n}} with n > 100, you could do dataTrimmed = Take[#,100]& /@ data and plot that. $\endgroup$ Commented Jul 6, 2013 at 13:58
  • $\begingroup$ @TeakeNutma, i get following error Take::take: Cannot take positions 1 through 100 in {0 0}. >> $\endgroup$
    – JavaCake
    Commented Jul 6, 2013 at 14:12
  • 2
    $\begingroup$ Looking at the sample data you provided, you might want to try: data[[1;;100]] (see Documentation Center for Span) (or see Transpose and then use @TeakeNutma's idea) $\endgroup$ Commented Jul 6, 2013 at 14:20

1 Answer 1

1
$\begingroup$

OK, quick example: Compare the first BarChart with the second one where I only used the first 5 elements of data

data = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}, {13, 14}};
BarChart[data]
BarChart[data[[;;5]]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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