Re: How to specify x-axis in List when using ListPlot
- To: mathgroup at smc.vnet.net
- Subject: [mg127877] Re: How to specify x-axis in List when using ListPlot
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Wed, 29 Aug 2012 01:13:05 -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: <20120828085322.A005168D4@smc.vnet.net>
data1 =
{{1, 8, 9, 1}, {2, 2, 8, 1}, {3, 8, 9, 2},
{4, 3, 7.5, 2}, {5, 3, 7.5, 1}};
Module[{
labels =
Style[#, Bold] & /@
{"Test", "Variable 1", "Variable 2", "Result "},
minResult = Min[data1[[All, 4]]],
maxResult = Max[data1[[All, 4]]]},
Graphics3D[{
AbsolutePointSize[8],
{ColorData["TemperatureMap"][
Rescale[#[[-1]], {minResult, maxResult}]],
Point[Rest[#]]} & /@
data1},
BoxRatios -> {1, 1, 1/GoldenRatio},
Axes -> True,
AxesLabel -> Rest[labels],
PlotLabel -> Style["TEST RESULTS\n", Bold],
ImageSize -> 400]]
Or with some embellishments:
Module[{
labels =
Style[#, Bold] & /@
{"Test", "Variable 1", "Variable 2", "Result "},
minResult = Min[data1[[All, 4]]],
maxResult = Max[data1[[All, 4]]]},
Panel[
Column[{
Graphics3D[{
AbsolutePointSize[8],
{ColorData["TemperatureMap"][
Rescale[#[[-1]], {minResult, maxResult}]],
Tooltip[
Point[Rest[#]],
"Test " <> ToString[First[#]] <>
"\nVar = " <>
ToString[#[[{2, 3}]]] <>
"\nResult = " <>
ToString[Last[#]]]} & /@
data1},
BoxRatios -> {1, 1, 1/GoldenRatio},
Axes -> True,
AxesLabel -> Rest[labels],
PlotLabel -> Style["TEST RESULTS\n", Bold],
ImageSize -> 400],
Grid[Prepend[data1, labels],
Frame -> All,
Background -> Lighter[Gray, .75]]},
Alignment -> Center]]]
Bob Hanlon
On Tue, Aug 28, 2012 at 4:53 AM, Jack Heanult <john.h.hayden 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.
>
- References:
- How to specify x-axis in List when using ListPlot
- From: Jack Heanult <john.h.hayden@gmail.com>
- How to specify x-axis in List when using ListPlot