Message Boards Message Boards

How do I change the colors and styles of two functions?

Posted 9 years ago

How do I change the colors and styles of two functions that are graphed on the same set of axes? The color and style needs to be different for each function, but they must be on the same graph. The screenshot I attached is what I have graphed so far. F[x] needs to be purple and dashed. And H[x] needs to be red and thick. (please help I've been trying to figure this out for 4 hours!)

Attachments:
POSTED BY: kendra s
6 Replies

It should work perfectly fine. However if you have not defined and executed your functions F and G in your current Mathematica session (not good names ass per my earlier suggestion) then you will get a blank graph. It would help if you posted your code as without it is is not easy to debug

POSTED BY: David Reiss
Posted 9 years ago

actually i just did it!! I had to go back up and redefine the functions and then after that it worked! thank you SO much!

POSTED BY: kendra s

Quick comments:

1) your definition of Graph should not be a delayed evaluation (:=), it should be an immediate evaluation (=).

2) you should use graph rather than Graph. Graph is a reserved Mathematica symbol. Generally it is a good idea to define your symbols starting with a lowercase letter to avoid this.

3) A safer and more powerful and unambiguous way to use PlotStyle is with Directive as in

graph = Plot[{x, x^2}, {x, -3, 3}, 
 PlotStyle -> {Directive[Purple, Thick, Dashed], Directive[Pink, Thick, Opacity[0.5]]}]
POSTED BY: David Reiss
Posted 9 years ago

That makes sense to me, but seemingly not to the program, as the functions have disappeared yet again

POSTED BY: kendra s

Add inside Plot command: PlotStyle->{{Dashed,Purple},{Thick,Red}}

POSTED BY: S M Blinder
Posted 9 years ago

I typed in PlotStyle -> {{Purple, Dashed}, {Red, Thick}} (the program wanted the colors to go before the styles) at the end of the plot command and it just made the functions disappear from the graph completely

POSTED BY: kendra s
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