Message Boards Message Boards

GROUPS:

[✓] Plot a function with two variables?

Posted 9 months ago
755 Views
|
7 Replies
|
2 Total Likes
|

Hi, Is there any command I can use to plot a function (minDiff) in two variables z, x . I don't want 3D plots and I tried contour plots, but it doesn't give me a result. this is my syntax:

z = {0.336`, 0.3365`, 0.337`, 0.3375`, 0.338`, 0.3385`, 0.339`, 
   0.3395`, 0.34`, 0.3405`, 0.341`, 0.3415`, 0.342`, 0.3425`, 0.343`, 
   0.3435`, 0.34400000000000003`, 0.34450000000000003`, 
   0.34500000000000003`, 0.34550000000000003`, 0.34600000000000003`, 
   0.34650000000000003`, 0.34700000000000003`, 0.34750000000000003`, 
   0.34800000000000003`, 0.34850000000000003`, 0.34900000000000003`, 
   0.34950000000000003`, 0.35000000000000003`, 0.35050000000000003`, 
   0.35100000000000003`, 0.35150000000000003`, 0.35200000000000004`};
x = {0.439`, 0.4395`, 0.44`, 0.4405`, 0.441`, 0.4415`, 0.442`, 
   0.4425`, 0.443`, 0.4435`, 0.444`, 0.4445`, 0.445`, 0.4455`, 0.446`,
    0.4465, 0.447`, 0.4475, 0.448`, 0.4485, 0.449`, 0.4495, 0.45`, 
   0.4505, 0.451`, 0.4515, 0.452`, 0.4525, 0.453`, 0.4535, 0.454`, 
   0.4545, 0.455`};
minDiff = {0.00003801029774402991`, 0.00003166395441034695`, 
   0.00002824280188019947`, 0.000024959958712714654, 
   0.000022787269822019383`, 0.000019436483137210108`, 
   0.00001693371175948988, 0.000015088165217656512`, 
   0.000012260361064817496`, 0.000010559861086240865`, 
   8.76936167283543`*^-6, 6.751339890899566`*^-6, 
   5.873151744268928`*^-6, 4.1299202056503785`*^-6, 
   2.9436141706752585`*^-6, 2.6963256370489514`*^-6, 
   1.204783793086779`*^-6, 8.73309714394511`*^-7, 
   6.580914927107429`*^-7, 2.9797119948788726`*^-8, 
   5.763762151984972`*^-7, 3.834617172196265`*^-7, 
   6.411511518542553`*^-7, 1.9380608650917353`*^-6, 
   1.908754472834736`*^-6, 3.074073348904814`*^-6, 
   4.3815787238334555`*^-6, 5.26905301873764`*^-6, 
   7.3638110225485615`*^-6, 8.673162659005944`*^-6, 
   0.000015202058022669781, 0.000013293830765242055};



tab11 = Table[{z[[i]], x[[i]], minDiff[[i]]}, {i, 1, Length[z]}];

ListContourPlot[tab11, FrameLabel -> {"\!\(\*
StyleBox[SubscriptBox[\"\[Kappa]\", \"z\"],\nFontSize->24]\)", 
   "\!\(\*
StyleBox[SubscriptBox[\"\[Kappa]\", \"x\"],\nFontSize->24]\)"}, 
 ContourStyle -> 
  Directive[AbsoluteThickness[3], Dashing[{.05, .05}], Black], 
 BaseStyle -> {FontWeight -> Bold, FontSize -> 14}, 
 ContourShading -> False, Contours -> 2]


Thanks.
7 Replies
Posted 9 months ago

I don't think you've quite provided us with everything required to help here. What is the definition of tab11? Can you minimize this at all to get rid of code that isn't directly relevant to the question at hand?

Posted 9 months ago

Thank you for your response. tab11 is the table I created for my data. my function is minDiff is the minimum cross section in two variables z is the horizontal axes and x is the vertical axes. my data now after solutions are the numbers as in the table (table).In other words, my function is minDiff(z,x) is like f(z,x), so I need to plot my function in two variables(z,x) which their values are in the table.

the last command is my attempt to contour plot. Hope this helps to understand what I need.

Thanks.

Posted 9 months ago

Thanks for providing that. Instead of a ContourPlot (I don't know if that is going to work well with your data), what about something like a ListPlot where the points are colored based on the third value?

listtest = Table[
  Style[{z[[i]], x[[i]]},
   Blend[{Red, Blue}, Rescale[minDiff[[i]], MinMax[minDiff], {0, 1}]]
   ],
  {i, 1, Length[minDiff]}]

ListPlot[listtest, 
 PlotLegends -> BarLegend[{Blend[{Red, Blue}, #] &, {0, 1}}]]

enter image description here

Posted 9 months ago

Thank you so much!! appreciated

Do you know what the wrong in my command for ContourPlot? because I used it previously for another function in two variables and it was working, but my data was huge.

Posted 9 months ago

Well, your data is pretty linear. My guess is that ContourPlot is not able to interpolate more general contours with data in that shape.

Posted 9 months ago

I am very thankful!

Posted 8 months ago

Hi, Do you have an idea how to plot this: if I have x and y axises and I want to determine points {x1,y1) as a line in xy, which is the best plot command to do this.;

 x = {0.025`, 0.025500000000000002`, 0.026000000000000002`, 
   0.026500000000000003`, 0.027000000000000003`, 0.0275`, 
   0.028000000000000004`, 0.0285`, 0.028999999999999998`, 
   0.029500000000000002`, 0.03`};

y = {0.075, 0.0755`, 0.076`, 0.0765`, 0.077`, 0.0775`, 0.078`, 
   0.0785`, 0.079`, 0.0795`, 0.08`};

x1 = {0.027000000000000003, 0.027000000000000003, 
   0.027000000000000003, 0.027000000000000003, 0.027000000000000003`, 
   0.027000000000000003`, 0.027000000000000003, 0.027000000000000003, 
   0.027000000000000003`, 0.027000000000000003, 0.0275`};

y1 = {0.075, 0.0755`, 0.076`, 0.0765`, 0.077`, 0.0775`, 0.078`, 
   0.0785`, 0.079`, 0.0795`, 0.08`};

Thanks.

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