Message Boards Message Boards

0
|
4708 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Plotting part of a function with the Wolfram Language?

Posted 9 years ago

Hi everyone, how could I get the following result with Wolfram Mathematica (the function is $sin(t)$ in $[\pi/2, 3\pi/4]$)?

enter image description here

Note that the first value of the orizontal axis is 0 (not $\pi/2$) and the last value is 10 (not $3\pi/4$). I tried with Plot[Piecewise[{{Sin[x], Pi/2 < x < 3*Pi/4}}], {0, 0, 10}], but it does not work.

Thank you for your time.

POSTED BY: Gennaro Arguzzi
3 Replies

Hi David, my goal is to get the same plot of the figure that I posted.

POSTED BY: Gennaro Arguzzi

Mathematica graphics uses many Options to tailor the plot. You might look up: (Copy the code and evaluate in a notebook.)

Options[Plot] // Column

I'm not certain exactly how you want your plot to look, but here is an attempt.

Plot[Sin[x], {x, \[Pi]/2, 3 \[Pi]/4},
 PlotStyle -> Black,
 PlotRange -> {{\[Pi]/2, 3 \[Pi]/4}, {0, 1}},
 PlotRangePadding -> {0.05, 0.05},
 Frame -> True,
 FrameTicks -> {Automatic, {{{\[Pi]/2, \[Pi]/
      2, {0.0125`, 0}, {Black, AbsoluteThickness[0.25`]}}, {(3 \[Pi])/
      4, (3 \[Pi])/
      4, {0.0125`, 0}, {Black, AbsoluteThickness[0.25`]}}}, {{\[Pi]/2,
       "", {0.0125`, 0}, {Black, AbsoluteThickness[0.25`]}}, {(
      3 \[Pi])/4, 
      "", {0.0125`, 0}, {Black, AbsoluteThickness[0.25`]}}}}},
 BaseStyle -> {FontSize -> 12}]

I actually got the ticks from a routine in my Presentations application, which I sell and you would have to contact me.

CustomTicks[Identity, databased[{\[Pi]/2, 3 \[Pi]/4}]]

giving

{{\[Pi]/2, \[Pi]/
  2, {0.0125, 0}, {GrayLevel[0.], AbsoluteThickness[0.25]}}, {(
  3 \[Pi])/4, (3 \[Pi])/
  4, {0.0125, 0}, {GrayLevel[0.], AbsoluteThickness[0.25]}}}

and

CustomTicks[Identity, databased[{\[Pi]/2, 3 \[Pi]/4}]] // NoTickLabels

which gives Ticks without the tick labels. But you would have to delve into the specifications for Ticks.

?Ticks

depending on what you want to see outside the Pi/2 and 3Pi/2:

Plot[Piecewise[{{Sin[x],Pi/2<x<3*Pi/2}}],{x,0,10}]
Plot[Sin[x],{x,\[Pi]/2,3Pi/2},PlotRange->{{0,10},{-1,1}}]
Plot[Piecewise[{{Sin[x],Pi/2<x<3*Pi/2},{1,x<Pi/2},{-1,True}}],{x,0,10}]
POSTED BY: Sander Huisman
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