Message Boards Message Boards

0
|
2723 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to skip some data points from ListPlot?

Posted 1 year ago

Hello,

I want to skip some points marked in circled from the plot. Here is my code

ClearAll["Global`*"];
\[Sigma] = 5;
Kn = {0.025, 0.1};
Subscript[\[Sigma], v] = 0.85;
Subscript[\[Alpha], v] = (2 - Subscript[\[Sigma], v])/
  Subscript[\[Sigma], v];
\[Alpha] = Subscript[\[Alpha], v] Kn;
u[r_, \[Alpha]_] := (\[Sigma] (BesselI[0, \[Sigma]] - 
     BesselI[0, 
      r \[Sigma]] + \[Alpha] \[Sigma] BesselI[
       1, \[Sigma]]))/(\[Sigma] BesselI[
     0, \[Sigma]] + (-2 + \[Alpha] \[Sigma]^2) BesselI[1, \[Sigma]]);

uth = Plot[
   {u[r, \[Alpha][[1]]], u[r, \[Alpha][[2]]]}, {r, 0, 1},
   PlotStyle -> {{Blue, Thick}, {Red, Thick}},
   PlotLegends -> Placed[{TraditionalForm["\!\(\*
StyleBox[\"Kn\",\nFontSlant->\"Italic\"]\)=0.025"], 
      TraditionalForm["\!\(\*
StyleBox[\"Kn\",\nFontSlant->\"Italic\"]\)=0.1"]}, {Left, Center}],
   LabelStyle -> {FontFamily -> "Times New Roman", 24, Bold}
   ];

unum = With[
   {
    data = 
     Import["C:\\Users\\KRISHAN\\Dropbox\\Journal Drafts\\Draft \
4\\Numerical study\\velocity uniform permeability.xlsx"]
    },
   ListPlot[
    {
     data[[1, All, {1, 2}]], data[[1, All, {1, 3}]]
     },
    PlotStyle -> {{Black, Thick}, {Black, Thick}}
    ]
   ];
Show[
 uth, unum, PlotRange -> {{0, Automatic}, {0, Automatic}},
 AxesOrigin -> {0, 0},
 AxesStyle -> {Black, Black},
 AxesLabel -> {r, "\!\(\*OverscriptBox[\(u\), \(^\)]\)"}
 ]

enter image description here

One way is to delete the data points from the excel file. But i want the points to be at equally distance or plot to look little decent. It looks a tedious job. I am attaching the excel file too. Please help.

POSTED BY: KRISHAN SHARMA
4 Replies

Thanks.

POSTED BY: KRISHAN SHARMA

what does exactly this line doing ...

it skips the first data entry which reads: {"r", "u kn=0.025", "u kn=0.1"} and is probably a header (strange that there was no error message). A cleaner solution would have been to import the Excel data like so:

data = Import[ ... , "HeaderLines" -> 1]
POSTED BY: Henrik Schachner
Posted 1 year ago

Thanks Henrik Schachner :) It worked.

data1 = data[[1, 2 ;;, {1, 2}]];

what does exactly this line doing when you are taking part ([[]]) of data (excel file)

POSTED BY: Updating Name

Krishan,

one way is simply to use equally spaced points along an interpolation of your original data:

unum = Module[{data, data1, data2, if1, if2, data1i, data2i}, 
   data = Import["C:\\Users\\KRISHAN\\Dropbox\\Journal Drafts\\Draft 4\\Numerical study\\velocity uniform permeability.xlsx"];
   data1 = data[[1, 2 ;;, {1, 2}]];
   data2 = data[[1, 2 ;;, {1, 3}]];
   {if1, if2} = Interpolation /@ {data1, data2}; 
   {data1i, data2i} = Transpose@Table[{{x, if1[x]}, {x, if2[x]}}, {x, 0, 1, .025}]; 
   ListPlot[{data1i, data2i}, PlotStyle -> {{Black, Thick}, {Black, Thick}}]];
POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract