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 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},...}
share|improve this question
    
How about PlotRange? –  Teake Nutma Jul 6 '13 at 13:46
    
@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. –  JavaCake Jul 6 '13 at 13:50
    
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. –  Teake Nutma Jul 6 '13 at 13:58
    
@TeakeNutma, i get following error Take::take: Cannot take positions 1 through 100 in {0 0}. >> –  JavaCake Jul 6 '13 at 14:12
2  
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) –  Pinguin Dirk Jul 6 '13 at 14:20
show 3 more comments

1 Answer

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]]]
share|improve this answer
add comment

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.