# Plotting three sets of points

I am trying to plot 3 sets of points. For example consider

Xfinal={{79.7752, -4.5745}, {79.7752, -4.57458}, {79.7751, -4.57453},
{79.8622, -4.36018}, {79.8621, -4.36023}, {79.8623, -4.36031},
{79.5962, -4.39891}, {79.5962, -4.39893}, {79.5962, -4.3989}}


I am making it into three sets:

Xfinala = Xfinal[[1 ;; 3, All]]
Xfinalb = Xfinal[[4 ;; 6, All]]
Xfinalc = Xfinal[[7 ;; 9, All]]


I am using the following commands to plot:

Plotx = ListPlot[Xfinala, PlotStyle -> {Thick, Red}]
Ploty = ListPlot[Xfinalb, PlotStyle -> {Thick, Green}]
Plotz = ListPlot[Xfinalc, PlotStyle -> {Thick, Blue}]
Plot1 = Show[Plotx, Ploty, Plotz]


Further, let

βa={-157.767, 1.42204, -9.90731}
βb={-649.437, 7.96711, -3.24825}


Now I am trying to plot the following lines together with points using the following codes:

Plotsvma =
Plot[-(1/βa[])*(βa[]*x + βa[]) , {x, -10, 10}]
Plotsvmb =
Plot[-(1/βb[])*(βb[]*x + βb[]) , {x, -10, 10}]


and finally:

Plotx = Show[Plot1, Plotsvma , Plotsvmb ]


But it is not displaying all the plots... Am I doing something wrong?

• add PlotRange->All to Show . – kglr Jul 22 '18 at 8:52
• Note that the because of very different scales in Plots and ListPlots all three points overlap in the output of Show. – kglr Jul 22 '18 at 8:53

Ok, your problem is the incompatible PlotRange of the plots you are trying to Show, that you can fix by hand or with PlotRange->All in Show as suggested by @kglr, while I was typing this answer.

I would do other things differently as well.

Xfinal = {{79.7752, -4.5745}, {79.7752, -4.57458}, {79.7751, \
-4.57453}, {79.8622, -4.36018}, {79.8621, -4.36023}, {79.8623, \
-4.36031}, {79.5962, -4.39891}, {79.5962, -4.39893}, {79.5962, \
-4.3989}}


Do a single ListPlot using Partition and Thread to avoid repeating code.

plot1 = ListPlot[
Partition[Xfinal, 3]
, PlotTheme -> "Scientific"
, PlotStyle -> Thread@{PointSize[Large], {Red, Green, Blue}}
];


Limit the use of global variables, using limited scope functions such as With

plotsvm = With[
{
βa = {-157.767, 1.42204, -9.90731},
βb = {-649.437, 7.96711, -3.24825}
},
Plot[
{
-(1/βa[])*(βa[]*x + βa[]),
-(1/βb[])*(βb[]*x + βb[])
}
, {x, 75, 95}
, PlotTheme -> "Scientific"
, FrameTicks -> True
]];

Show[plotsvm, plot1] • Hi, This is good. I reccomend a small change {x, (Min /@ Transpose[Xfinal])[], (Max /@ Transpose[Xfinal])[]} instead of {x, 75, 95}. – kosa Jul 23 '18 at 7:57