0
$\begingroup$

I am trying to plot the normalized approximate solution of x against the parameter h in simple pendulum. On the graph are two solutions that overlap (One for exact and the other for numerical). Please, can anyone show me how to distinctively draw the graphs. I want something like dashline and triangle, for dissimilarity. Here are my codes.

p1 = ListLinePlot[
   Table[{Hle1Values[[i]], yle1Values[[i]]/Subscript[\[Theta], 
     0]}, {i, 1, Steps}], PlotStyle -> {DotDashed, Thick}];


p2 = ListLinePlot[
   Table[{Hle1Values[[i]], approx11[[i]]/Subscript[\[Theta], 0]}, {i, 
     1, Steps}], PlotStyle -> {Dashed, Black}];


Show[p1, p2, AxesLabel -> {"h", "x"}]

The graph is given below

Equation of x vs h

For data set

$\left( \begin{array}{ccc} \frac{\text{yle1Values}[[i]]}{\theta _0} & \text{Hle1Values[[i]]} & \frac{\text{approx11}[[i]]}{\theta _0} \\ 0.999602 & 0.00513408 & 2.09355 \\ 0.998408 & 0.0102682 & 2.091 \\ 0.996416 & 0.0154022 & 2.08675 \\ 0.993624 & 0.0205363 & 2.08079 \\ 0.990027 & 0.0256704 & 2.07312 \\ 0.985621 & 0.0308045 & 2.06373 \\ 0.9804 & 0.0359386 & 2.05262 \\ 0.974358 & 0.0410726 & 2.03976 \\ 0.967486 & 0.0462067 & 2.02516 \\ 0.959777 & 0.0513408 & 2.00879 \\ 0.951222 & 0.0564749 & 1.99065 \\ 0.941811 & 0.061609 & 1.97072 \\ 0.931535 & 0.0667431 & 1.94898 \\ 0.920384 & 0.0718771 & 1.92541 \\ 0.908346 & 0.0770112 & 1.90001 \\ 0.895413 & 0.0821453 & 1.87275 \\ 0.881574 & 0.0872794 & 1.84362 \\ 0.86682 & 0.0924135 & 1.8126 \\ 0.851142 & 0.0975475 & 1.77968 \\ 0.834532 & 0.102682 & 1.74483 \\ 0.816982 & 0.107816 & 1.70806 \\ 0.798486 & 0.11295 & 1.66934 \\ 0.779041 & 0.118084 & 1.62868 \\ 0.758644 & 0.123218 & 1.58605 \\ 0.737294 & 0.128352 & 1.54146 \\ 0.714992 & 0.133486 & 1.49492 \\ 0.691742 & 0.13862 & 1.44641 \\ 0.667551 & 0.143754 & 1.39597 \\ 0.642428 & 0.148888 & 1.34359 \\ 0.616386 & 0.154022 & 1.2893 \\ 0.589439 & 0.159157 & 1.23313 \\ 0.561607 & 0.164291 & 1.1751 \\ 0.532913 & 0.169425 & 1.11527 \\ 0.503382 & 0.174559 & 1.05368 \\ 0.473044 & 0.179693 & 0.990381 \\ 0.441934 & 0.184827 & 0.925445 \\ 0.410088 & 0.189961 & 0.858943 \\ 0.377547 & 0.195095 & 0.790956 \\ 0.344357 & 0.200229 & 0.721575 \\ 0.310565 & 0.205363 & 0.6509 \\ 0.276224 & 0.210497 & 0.579037 \\ 0.241388 & 0.215631 & 0.506101 \\ 0.206115 & 0.220765 & 0.432215 \\ 0.170465 & 0.2259 & 0.357508 \\ 0.134501 & 0.231034 & 0.282115 \\ 0.0982873 & 0.236168 & 0.206176 \\ 0.0618909 & 0.241302 & 0.129836 \\ 0.0253789 & 0.246436 & 0.0532421 \\ -0.0111807 & 0.25157 & -0.023456 \\ -0.0477193 & 0.256704 & -0.100108 \\ -0.0841686 & 0.261838 & -0.176564 \\ -0.120461 & 0.266972 & -0.252676 \\ -0.15653 & 0.272106 & -0.328298 \\ -0.192309 & 0.27724 & -0.403288 \\ -0.227736 & 0.282374 & -0.477509 \\ -0.262749 & 0.287509 & -0.550828 \\ -0.297289 & 0.292643 & -0.623122 \\ -0.331301 & 0.297777 & -0.694272 \\ -0.36473 & 0.302911 & -0.764168 \\ -0.397529 & 0.308045 & -0.832707 \\ -0.42965 & 0.313179 & -0.899796 \\ -0.46105 & 0.318313 & -0.96535 \\ -0.491692 & 0.323447 & -1.02929 \\ -0.52154 & 0.328581 & -1.09155 \\ -0.550563 & 0.333715 & -1.15208 \\ -0.578733 & 0.338849 & -1.21081 \\ -0.606026 & 0.343983 & -1.2677 \\ -0.632421 & 0.349118 & -1.32273 \\ -0.657903 & 0.354252 & -1.37585 \\ -0.682458 & 0.359386 & -1.42705 \\ -0.706074 & 0.36452 & -1.47631 \\ -0.728744 & 0.369654 & -1.52362 \\ -0.750465 & 0.374788 & -1.56897 \\ -0.771232 & 0.379922 & -1.61235 \\ -0.791047 & 0.385056 & -1.65378 \\ -0.80991 & 0.39019 & -1.69325 \\ -0.827827 & 0.395324 & -1.73078 \\ -0.844802 & 0.400458 & -1.76637 \\ -0.860841 & 0.405592 & -1.80004 \\ -0.875953 & 0.410726 & -1.8318 \\ -0.890146 & 0.415861 & -1.86166 \\ -0.90343 & 0.420995 & -1.88964 \\ -0.915814 & 0.426129 & -1.91576 \\ -0.927308 & 0.431263 & -1.94004 \\ -0.937923 & 0.436397 & -1.96249 \\ -0.947669 & 0.441531 & -1.98312 \\ -0.956555 & 0.446665 & -2.00196 \\ -0.964592 & 0.451799 & -2.01901 \\ -0.971788 & 0.456933 & -2.0343 \\ -0.978151 & 0.462067 & -2.04783 \\ -0.98369 & 0.467201 & -2.05962 \\ -0.988412 & 0.472335 & -2.06968 \\ -0.992323 & 0.47747 & -2.07801 \\ -0.995427 & 0.482604 & -2.08464 \\ -0.997729 & 0.487738 & -2.08955 \\ -0.999233 & 0.492872 & -2.09276 \\ -0.99994 & 0.498006 & -2.09427 \\ -0.999851 & 0.50314 & -2.09408 \\ -0.998967 & 0.508274 & -2.09219 \\ -0.997285 & 0.513408 & -2.0886 \\ -0.994804 & 0.518542 & -2.08331 \\ -0.99152 & 0.523676 & -2.0763 \\ -0.987429 & 0.52881 & -2.06758 \\ -0.982525 & 0.533944 & -2.05714 \\ -0.976803 & 0.539079 & -2.04496 \\ -0.970254 & 0.544213 & -2.03104 \\ -0.962871 & 0.549347 & -2.01536 \\ -0.954646 & 0.554481 & -1.99791 \\ -0.945569 & 0.559615 & -1.97867 \\ -0.93563 & 0.564749 & -1.95763 \\ -0.92482 & 0.569883 & -1.93478 \\ -0.913128 & 0.575017 & -1.9101 \\ -0.900544 & 0.580151 & -1.88356 \\ -0.887058 & 0.585285 & -1.85516 \\ -0.87266 & 0.590419 & -1.82487 \\ -0.857342 & 0.595553 & -1.79269 \\ -0.841094 & 0.600687 & -1.7586 \\ -0.82391 & 0.605822 & -1.72257 \\ -0.805783 & 0.610956 & -1.68461 \\ -0.786707 & 0.61609 & -1.6447 \\ -0.76668 & 0.621224 & -1.60284 \\ -0.7457 & 0.626358 & -1.55901 \\ -0.723767 & 0.631492 & -1.51323 \\ -0.700885 & 0.636626 & -1.46548 \\ -0.677059 & 0.64176 & -1.41579 \\ -0.652296 & 0.646894 & -1.36416 \\ -0.626609 & 0.652028 & -1.31061 \\ -0.600011 & 0.657162 & -1.25517 \\ -0.572521 & 0.662296 & -1.19786 \\ -0.544159 & 0.667431 & -1.13872 \\ -0.514949 & 0.672565 & -1.07781 \\ -0.484921 & 0.677699 & -1.01516 \\ -0.454107 & 0.682833 & -0.950857 \\ -0.422542 & 0.687967 & -0.884954 \\ -0.390266 & 0.693101 & -0.817533 \\ -0.357323 & 0.698235 & -0.748683 \\ -0.323759 & 0.703369 & -0.678498 \\ -0.289624 & 0.708503 & -0.607083 \\ -0.254974 & 0.713637 & -0.534549 \\ -0.219863 & 0.718771 & -0.461018 \\ -0.184352 & 0.723905 & -0.386614 \\ -0.148503 & 0.72904 & -0.311471 \\ -0.112378 & 0.734174 & -0.235727 \\ -0.0760451 & 0.739308 & -0.159525 \\ -0.0395699 & 0.744442 & -0.0830125 \\ -0.00302068 & 0.749576 & -0.00633709 \\ 0.0335342 & 0.75471 & 0.0703507 \\ 0.0700263 & 0.759844 & 0.146901 \\ 0.106388 & 0.764978 & 0.223164 \\ 0.142551 & 0.770112 & 0.298993 \\ 0.17845 & 0.775246 & 0.374245 \\ 0.214022 & 0.78038 & 0.448781 \\ 0.249203 & 0.785514 & 0.522465 \\ 0.283933 & 0.790649 & 0.595172 \\ 0.318157 & 0.795783 & 0.66678 \\ 0.351818 & 0.800917 & 0.737176 \\ 0.384868 & 0.806051 & 0.806253 \\ 0.417257 & 0.811185 & 0.873916 \\ 0.448942 & 0.816319 & 0.940076 \\ 0.479883 & 0.821453 & 1.00465 \\ 0.510043 & 0.826587 & 1.06757 \\ 0.53939 & 0.831721 & 1.12878 \\ 0.567894 & 0.836855 & 1.18821 \\ 0.59553 & 0.841989 & 1.24582 \\ 0.622277 & 0.847123 & 1.30158 \\ 0.648115 & 0.852257 & 1.35544 \\ 0.673031 & 0.857392 & 1.40739 \\ 0.697013 & 0.862526 & 1.45741 \\ 0.720052 & 0.86766 & 1.50547 \\ 0.742141 & 0.872794 & 1.55158 \\ 0.763279 & 0.877928 & 1.59573 \\ 0.783464 & 0.883062 & 1.63792 \\ 0.802696 & 0.888196 & 1.67815 \\ 0.82098 & 0.89333 & 1.71644 \\ 0.83832 & 0.898464 & 1.75278 \\ 0.854722 & 0.903598 & 1.78719 \\ 0.870193 & 0.908732 & 1.81969 \\ 0.884742 & 0.913866 & 1.85029 \\ 0.898378 & 0.919001 & 1.879 \\ 0.91111 & 0.924135 & 1.90584 \\ 0.922949 & 0.929269 & 1.93083 \\ 0.933904 & 0.934403 & 1.95398 \\ 0.943986 & 0.939537 & 1.97532 \\ 0.953205 & 0.944671 & 1.99485 \\ 0.961571 & 0.949805 & 2.0126 \\ 0.969092 & 0.954939 & 2.02857 \\ 0.975778 & 0.960073 & 2.04278 \\ 0.981636 & 0.965207 & 2.05525 \\ 0.986675 & 0.970341 & 2.06598 \\ 0.9909 & 0.975475 & 2.07498 \\ 0.994317 & 0.98061 & 2.08227 \\ 0.99693 & 0.985744 & 2.08784 \\ 0.998744 & 0.990878 & 2.09171 \\ 0.99976 & 0.996012 & 2.09388 \\ 0.99998 & 1.00115 & 2.09435 \\ 0.999405 & 1.00628 & 2.09312 \\ 0.998033 & 1.01141 & 2.0902 \\ 0.995863 & 1.01655 & 2.08556 \\ 0.992891 & 1.02168 & 2.07923 \\ 0.989114 & 1.02682 & 2.07117 \\ \end{array} \right)$

$\endgroup$
  • $\begingroup$ The input should be provided in cut-and-pastable form.Please post All actual code rather than an image of code. $\endgroup$ – Mariusz Iwaniuk Mar 1 '18 at 20:36
  • $\begingroup$ @ Mariusz Iwaniuk. Alright, let me try. $\endgroup$ – Omojola Mar 1 '18 at 20:38
  • $\begingroup$ Yours code dosen't work .Please post minimal working code?. $\endgroup$ – Mariusz Iwaniuk Mar 1 '18 at 20:49
  • $\begingroup$ @ Mariusz Iwaniuk. It wouldn't work except I present the data set. I have just provided the data set. You can hover your way around it now. $\endgroup$ – Omojola Mar 1 '18 at 20:59
2
$\begingroup$

See demo code below:

$Version
(* "11.2.0 for Microsoft Windows (64-bit) (September 11, 2017)" *)

Steps = 10;
p1 = ListPlot[Table[{i, Sin[i]}, {i, 1, Steps, 0.5}], 
PlotMarkers -> {"\[RightTriangle]", 20}, PlotStyle -> {Blue}, 
AxesLabel -> {"h", "x"}, PlotLabel -> "DATA 1 and DATA 2", 
PlotLabels -> {"DATA 1"}, PlotLegends -> {"DATA 1"}];
p2 = ListLinePlot[Table[{i, Sin[i] + RandomReal[{-0.01, 0.01}]}, {i, 1, Steps, 0.1}],
PlotLabels -> {Callout["DATA 2", {Scaled[0.5], Above}]}, 
PlotLabels -> {"DATA 2"}, PlotLegends -> {"DATA 2"}];

Show[p1, p2] (* See in Help : Show -> Possible Issues. *)

enter image description here

EDITED:

Using PlotMarkers. You can choose symbols form: Palettes-> Basic Math Assistant->Typesetting->.

Steps = 10;
p1 = ListPlot[Table[{i, Sin[i]}, {i, 1, Steps, 0.4}], 
PlotMarkers -> {"\[RightTriangle]", 20}, PlotStyle -> {Red}];(*ListPlot Not ListLinePlot*)
p2 = ListLinePlot[
Table[{i, Sin[i] + RandomReal[{-0.01, 0.01}]}, {i, 1, Steps, 0.1}],
PlotStyle -> {Black}];
Show[p1, p2, AxesLabel -> {"h", "x"}]

enter image description here

Alternative:

Execute this code below:

Graphics[Polygon[CirclePoints[3]], ImageSize -> 20]

Hover over graphics, right mouse button -> Copy Graphics then paste to PlotMarkers. .

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ @ Mariusz Iwaniuk. Thank you very much! It was really helpful! One more thing, how can I plot triangle instead of the green color? $\endgroup$ – Omojola Mar 1 '18 at 21:16
  • $\begingroup$ @Omojola. I edited ma answer. $\endgroup$ – Mariusz Iwaniuk Mar 1 '18 at 22:10
  • $\begingroup$ @ Mariusz Iwaniuk. I am very grateful for this. God bless you! $\endgroup$ – Omojola Mar 1 '18 at 23:22
  • $\begingroup$ @ Mariusz Iwaniuk, please how can I label the first one? It seems not work here. You know we are combining ListPlot and ListLinePlot. Kindly edit the first example. $\endgroup$ – Omojola Mar 3 '18 at 2:38
  • $\begingroup$ @Omojola.I edited first example. $\endgroup$ – Mariusz Iwaniuk Mar 3 '18 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.