MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to specify x-axis in List when using ListPlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127874] Re: How to specify x-axis in List when using ListPlot
  • From: "Dr. Wolfgang Hintze" <weh at snafu.de>
  • Date: Wed, 29 Aug 2012 01:12:04 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <k1i0rg$4p2$1@smc.vnet.net>

On 28 Aug., 10:53, Jack Heanult <john.h.hay... at gmail.com> wrote:
> I have imported a csv file into a list with this stmt:
>
> data1 = Take[Import["D:\_reports\optim_5_60_b_2.csv", "CSV"], 5]
>
> Which gives:
>
> {{1, 8, 9, 1}, {2, 2, 8, 1}, {3, 8, 9, 2}, {4, 3, 7.5, 2}, {5, 3, 7.5, 1}}
>
> I would like to create a plot where the x-axis is based on the first field:
>
> 1,2,3,4,5
>
> And the plot creates a line for each subsequent field, so the 2nd fields are:
>
> 8,2,8,3,3 and this would be plotted as a line.
>
> This would be the first line on the y-axis, the other y-axis values would be plotted in the same manner. I would like the first y-plot to be plotted in red, and the second in blue, and the third in green with chart labels.
>
> Just to get it to plot I have tried:
> tobeplotted =  With[{LocalX = data1[[All, 1]]},
>    Transpose[{LocalX, #}] & /@ Transpose[data1[[All, 2 ;;]]]]
>
> ListPlot[tobeplotted, PlotStyle -> {Red, Blue, Green},  PlotMarkers -> {Automatic, 10}]
>
> But the resulting plot is not what I want.
>
> The first column in the csv file is the 'test number' (1) the 2nd(8), 3rd (9), are the test variables, and the 4th(1) column is the result. I would like to see how the test results vary as the variables change. Perhaps ListPlot is not what I want, it was my thought just to see something similar to what I can do in a Excel graph.
>
> Any help is most appreciated.

Maybe I misunderstood something, but what's wrong with these very
simple commands, which create a colored graph of you data?

In[1]:= t = {{1, 8, 9, 1}, {2, 2, 8, 1}, {3, 8, 9, 2}, {4, 3, 7.5, 2},
{5, 3, 7.5, 1}}

Out[1]= {{1, 8, 9, 1}, {2, 2, 8, 1}, {3, 8, 9, 2}, {4, 3, 7.5, 2}, {5,
3, 7.5, 1}}

In[4]:= tt = Transpose[t]

Out[4]= {{1, 2, 3, 4, 5}, {8, 2, 8, 3, 3}, {9, 8, 9, 7.5, 7.5}, {1, 1,
2, 2, 1}}

In[6]:= ListPlot[Drop[tt, 1], PlotJoined -> True]

Best regards,
Wolfgang



  • Prev by Date: Luke's list of mathematica questions
  • Next by Date: Re: Problems obtaining a free c compiler...
  • Previous by thread: Re: How to specify x-axis in List when using ListPlot
  • Next by thread: Re: How to specify x-axis in List when using ListPlot