4
$\begingroup$

I have values of Irf and frequencies and I need to plot a graph, which I did. Code:

Irf = List[0.0897, 0.2692, 0.4487, 0.62831, 0.8078, 0.8078, 0.6283, 
   0.4487, 0.2692, 0.0897];
Freq = List[1.4814, 2.4691, 3.9506, 5.9259, 8.3950, 10.8641, 9.3827, 
   6.4197, 3.9506, 1.4814];
Both = Transpose[{Irf, Freq}]
ListPlot[Both, PlotRange -> {Full, Full}, Joined -> True, 
 Frame -> True, Frame -> True, 
 FrameLabel -> {Row[{Style["Irf (mA)", FontSlant -> Italic, 
      FontSize -> 15]}], 
   Row[{Style["Frequency (GHz)", FontSlant -> Italic, 
      FontSize -> 15]}]}, PlotRange -> Full(*{{0,0.045},{0,8}}*), 
 LabelStyle -> Blue
 , FrameTicksStyle -> Directive[Orange, 15], ImageSize -> 900, 
 PlotStyle -> {Red}, Joined -> True, AspectRatio -> 0.5, 
 Epilog -> {PointSize[0.01], Point[Both]}]

enter image description here I want to divide graph on two, using two different collors. For example first five points will be red, and the other five - green. How can i do it?

$\endgroup$
  • 1
    $\begingroup$ ListPlot[{Both[[;; 5]], Both[[6 ;;]]}, PlotStyle -> {Red, Green}, <the rest of your options here>]. In general you want to look at Part $\endgroup$ – Jason B. Apr 17 '17 at 22:00
  • 1
    $\begingroup$ Small tunning of your code,just change your Point[Both] into Riffle[{Red, Green}, Point /@ Partition[Both, 5]] $\endgroup$ – yode Apr 17 '17 at 22:01
2
$\begingroup$
ListPlot[{Both, Both[[;; 5]], Both[[6 ;;]]}, PlotRange -> Full, 
 Joined -> {True, False, False}, Frame -> True, 
 BaseStyle -> PointSize[Large], PlotStyle -> {Blue, Red, Green}, 
 AspectRatio -> 0.5]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Thank you. I have one more question: How can we change color of the line between points? $\endgroup$ – John Apr 17 '17 at 22:28
  • 1
    $\begingroup$ @John, the first color in the setting of PlotStyle is the color of the lines between points, that is PlotStyle -> {Blue, Red, Green} makes the lines blue. $\endgroup$ – kglr Apr 17 '17 at 22:40

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.