I have a BarChart used to show traffic on a network interface. I have data for every 0.5s, upto 1 min, which gives a lot of points. Is there a way to make it look less chaotic and messy?

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

maxValues = 121;
labelValues = Range[0.0, maxValues*0.5, 0.5];
        data[[1 ;; maxValues]],
        ChartLegends -> Placed[{"Outbound (TX)", "Inbound (RX)"}, {{0.5, 0}}],
        ChartLabels -> {labelValues, None},
        AxesLabel -> {"Duration [s]", "Bandwidth [byte/s]"}
     ImageSize -> 600,
     BaseStyle -> {12, FontFamily -> "Helvetica"},
     PlotRange -> All

The result

enter image description here

It's evident that the ticks and ChartLabels in the resulting BarChart look awful.

  • $\begingroup$ I think this issue has often been discussed before - searching previous questions will save everyone's time! $\endgroup$ – cormullion Jul 6 '13 at 17:16
  • 1
    $\begingroup$ You might want to also try thinking about what you want to convey with your chart before plotting it. Just because you have data streaming in at a high sample rate does not necessarily mean that you need to also present it at the same rate. For example with car traffic, it makes sense to use a unit of time that is meaningful — for instance, "# of cars per minute" for the Los Angeles freeway in California or "# of cars per day" for a country road in England. In such cases, it is prudent to re-bin your data and then plot. If not, perhaps there are better representations than a barchart $\endgroup$ – rm -rf Jul 6 '13 at 17:58
  • $\begingroup$ @rm-rf, i am thankful for your concern, but this chart and representation is exactly what i need. $\endgroup$ – JavaCake Jul 6 '13 at 18:07
  • $\begingroup$ @JavaCake Ok, sounds good, and looks like cormullion's answer is what you were looking for :) I'll leave the comment up, as a general observation. $\endgroup$ – rm -rf Jul 6 '13 at 18:14
  • $\begingroup$ @rm-rf, it is exactly what i needed, the only problem i have left is the axes values in the duration-axis which has to be from [0:60] representing 1min measurement. I am not certain how this can be modified. $\endgroup$ – JavaCake Jul 6 '13 at 18:17

With so much data, this is the best I could manage:

BarChart[RandomInteger[300, {120, 2}],
 ChartLegends -> Placed[{"Outbound (TX)", "Inbound (RX)"}, {{0.5, 0}}],
 ChartStyle ->
   Directive[Orange, EdgeForm[None]],
   Directive[Blue, EdgeForm[None]]
 Frame -> True,
 BarSpacing -> 2,
 FrameLabel -> {"duration (minutes:seconds)", "bandwidth"},
 ImageSize -> 500,
 BaseStyle -> {12, FontFamily -> "Helvetica"},
 TicksStyle -> Directive[Opacity[0]],
 FrameTicks -> {
   {Automatic, None},
   {Table[{x, DateString[x, {"Minute", ":", "Second"}]}, {x, 0, 360, 
      30}] , None}},
 PlotRange -> All]

new version

  • $\begingroup$ A world of difference. Is there a chance that i can change the axes numbers of duration to [0.5:60]? $\endgroup$ – JavaCake Jul 6 '13 at 17:16
  • $\begingroup$ @JavaCake The online reference has lots of information about Ticks and FrameTicks, and there are many existing questions here about them too. Have a play with the options. $\endgroup$ – cormullion Jul 6 '13 at 21:16
  • $\begingroup$ lastly i have a question. When i have data points for [1:120], why does the ticks value exceed 120? $\endgroup$ – JavaCake Jul 7 '13 at 1:58
  • 1
    $\begingroup$ @JavaCake Perhaps the BarSpacing option should be adjusted, eg to {1,1}? $\endgroup$ – cormullion Jul 7 '13 at 7:21

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.