脳卒中左片麻痺になりました

twitter http://twitter.com/#!/ti5942

2011年02月

screenshot1fig5

fig5.draw
****
unit 1cm,1cm
range -2,2,-4,5

# 逆関数
linewidth 1
dplot red,-4,5,sin(\x r),\x
plot red,-pi/2,pi/2,sin(\x r),\x

linewidth 0
dline black,-1,-4,-1,5
dline black,1,-4,1,5
point black,-1,0,below left,$-1$
point black,0,0,below right,$O$
point black,1,0,below right,$1$
dline black,-1,3*pi/2,0,3*pi/2
point black,0,pi,above right,$\pi$
dline black,1,pi/2,0,pi/2
point black,0,pi/2,left,$\dfrac{\pi}{2}$
dline black,-1,-pi/2,0,-pi/2
point black,0,-pi/2,right,$-\dfrac{\pi}{2}$
point black,0,-pi,right,$-\pi$
****

fig5.tex
****
\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usepackage{amsmath}
\usepackage{myjapanese}
\usepackage{mypreview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}% 余白

\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\draw[->,color=gray] ({-2},{0}) -- ({2},{0}) node[right] {$x軸$};
\draw[->,color=gray] ({0},{-4}) -- ({0},{5}) node[above] {$y軸$};
\clip(-2,-4) rectangle (2,5);
\draw[color=red,dashed,smooth,samples=100,domain={-4}:{5},line width=1.0pt] plot({sin(\x r)},{\x}) node [] {};
\draw[color=red, smooth,samples=100,domain={-pi/2}:{pi/2},line width=1.0pt] plot({sin(\x r)},{\x}) node [] {};
\draw [dashed,color=black,line width=0.0pt] ({-1},{-4}) -- ({-1},{5}) node [] {};
\draw [dashed,color=black,line width=0.0pt] ({1},{-4}) -- ({1},{5}) node [] {};
\fill [color=black] ({-1},{0}) circle (0.0pt) node [below left] {$-1$};
\fill [color=black] ({0},{0}) circle (0.0pt) node [below right] {$O$};
\fill [color=black] ({1},{0}) circle (0.0pt) node [below right] {$1$};
\draw [dashed,color=black,line width=0.0pt] ({-1},{3*pi/2}) -- ({0},{3*pi/2}) node [] {};
\fill [color=black] ({0},{pi}) circle (0.0pt) node [above right] {$\pi$};
\draw [dashed,color=black,line width=0.0pt] ({1},{pi/2}) -- ({0},{pi/2}) node [] {};
\fill [color=black] ({0},{pi/2}) circle (0.0pt) node [left] {$\dfrac{\pi}{2}$};
\draw [dashed,color=black,line width=0.0pt] ({-1},{-pi/2}) -- ({0},{-pi/2}) node [] {};
\fill [color=black] ({0},{-pi/2}) circle (0.0pt) node [right] {$-\dfrac{\pi}{2}$};
\fill [color=black] ({0},{-pi}) circle (0.0pt) node [right] {$-\pi$};
\end{tikzpicture}
\end{document}
****

コマンド入力
ti5942@Ubuntu:~/RUBY$ ruby draw2tikz.rb <fig5.draw>fig5.tex
ti5942@Ubuntu:~/RUBY$ xelatex fig5.tex
・・・
ti5942@Ubuntu:~/RUBY$ pdftoppm -png fig5.pdf>fig5.png

とりあえず\usepackage{amsmath} 追加
破線をdashedに統一
dplotはplotの破線版
ソース
****
line_width = 0

puts "\\documentclass[10pt]{article}"
puts "\\usepackage{pgf,tikz}"
puts "\\usepackage{amsmath}"

puts "\\usepackage{myjapanese}"
puts "\\usepackage{mypreview}"
puts "\\PreviewEnvironment{tikzpicture}"
puts "\\setlength\\PreviewBorder{5pt}% 余白"
puts
puts "\\usetikzlibrary{arrows}"
puts "\\pagestyle{empty}"
puts "\\begin{document}"

while line = gets
    l = line.chop.split(/\s/,2)
    case l[0]
    when "unit"
        l0 = l[1].split(/,/)
        ux = l0[0]
        uy = l0[1]
        puts "\\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=#{ux},y=#{uy}]"
    when "range"
        l0 = l[1].split(/,/)
        x1 = l0[0]
        x2 = l0[1]
        y1 = l0[2]
        y2 = l0[3]
        puts "\\draw[->,color=gray] ({#{x1}},{0}) -- ({#{x2}},{0}) node[right] {$x軸$};" # x軸
        puts "\\draw[->,color=gray] ({0},{#{y1}}) -- ({0},{#{y2}}) node[above] {$y軸$};" # y軸
        puts "\\clip(#{x1},#{y1}) rectangle (#{x2},#{y2});"
    when "linewidth"
        l0 = l[1].split(/,/)
        line_width = l0[0].to_f
    when "plot", "dplot"
        l0 = l[1].split(/,/,7)
        s_color =  l0[0]
        d1 = l0[1]
        d2 = l0[2]
        p_f = l0[3]
        p_g = l0[4]
        locate = l0[5]
        text = l0[6]
        if l[0] == "plot"
            puts "\\draw[color=#{s_color}, smooth,samples=100,domain={#{d1}}:{#{d2}},line width=#{line_width}pt] plot({#{p_f}},{#{p_g}}) node [#{locate}] {#{text}};"
        else
            puts "\\draw[color=#{s_color},dashed,smooth,samples=100,domain={#{d1}}:{#{d2}},line width=#{line_width}pt] plot({#{p_f}},{#{p_g}}) node [#{locate}] {#{text}};"
        end
    when "arrow", "darrow"
        l0 = l[1].split(/,/,7)
        s_color =  l0[0]
        x1 = l0[1]
        y1 = l0[2]
        x2 = l0[3]
        y2 = l0[4]
        locate = l0[5]
        text = l0[6]
        if l[0] == "arrow"
            puts "\\draw [->,color=#{s_color},line width=#{line_width}pt] ({#{x1}},{#{y1}}) -- ({#{x2}},{#{y2}}) node [#{locate}] {#{text}};"
        else
            puts "\\draw [->,dashed,color=#{s_color},line width=#{line_width}pt] ({#{x1}},{#{y1}}) -- ({#{x2}},{#{y2}}) node [#{locate}] {#{text}};"
        end
    when "line", "dline"
        l0 = l[1].split(/,/,7)
        s_color = l0[0]
        x1 = l0[1]
        y1 = l0[2]
        x2 = l0[3]
        y2 = l0[4]
        locate = l0[5]
        text = l0[6]
        if l[0] == "line"
            puts "\\draw [color=#{s_color},line width=#{line_width}pt] ({#{x1}},{#{y1}}) -- ({#{x2}},{#{y2}}) node [#{locate}] {#{text}};"
        else
            puts "\\draw [dashed,color=#{s_color},line width=#{line_width}pt] ({#{x1}},{#{y1}}) -- ({#{x2}},{#{y2}}) node [#{locate}] {#{text}};"
        end
    when "point"
        l0 = l[1].split(/,/,5)
        s_color = l0[0]
        x = l0[1]
        y = l0[2]
        locate = l0[3]
        text = l0[4]
        puts "\\fill [color=#{s_color}] ({#{x}},{#{y}}) circle (#{line_width}pt) node [#{locate}] {#{text}};"
    when "grid"
        l0 = l[1].split(/,/)
        s_color = l0[0]
        step = l0[1]
        x1 = l0[2]
        y1 = l0[3]
        x2 = l0[4]
        y2 = l0[5]
        puts "\\draw[step=#{step},color=#{s_color}] ({#{x1}},{#{y1}}) grid ({#{x2}},{#{y2}});"
    end
end

puts "\\end{tikzpicture}"
puts "\\end{document}"
****

****
line_width = 0

puts "\\documentclass[10pt]{article}"
puts "\\usepackage{pgf,tikz}"
puts
puts "\\usepackage{myjapanese}"
puts "\\usepackage{mypreview}"
puts "\\PreviewEnvironment{tikzpicture}"
puts "\\setlength\\PreviewBorder{5pt}% 余白"
puts
puts "\\usetikzlibrary{arrows}"
puts "\\pagestyle{empty}"
puts "\\begin{document}"

while line = gets
    l = line.chop.split(/\s/,2)
    case l[0]
    when "unit"
        l0 = l[1].split(/,/)
        ux = l0[0]
        uy = l0[1]
puts "\\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=#{ux},y=#{uy}]"
    when "range"
        l0 = l[1].split(/,/)
        x1 = l0[0]
        x2 = l0[1]
        y1 = l0[2]
        y2 = l0[3]
puts "\\draw[->,color=gray] ({#{x1}},{0}) -- ({#{x2}},{0}) node[right] {$x軸$};" # x軸
puts "\\draw[->,color=gray] ({0},{#{y1}}) -- ({0},{#{y2}}) node[above] {$y軸$};" # y軸
puts "\\clip(#{x1},#{y1}) rectangle (#{x2},#{y2});"
    when "linewidth"
        l0 = l[1].split(/,/)
        line_width = l0[0].to_f
    when "plot"
        l0 = l[1].split(/,/,7)
        s_color =  l0[0]
        d1 = l0[1]
        d2 = l0[2]
        p_f = l0[3]
        p_g = l0[4]
        locate = l0[5]
        text = l0[6]
puts "\\draw[color=#{s_color}, smooth,samples=100,domain={#{d1}}:{#{d2}},line width=#{line_width}pt] plot({#{p_f}},{#{p_g}}) node [#{locate}] {#{text}};"
    when "arrow"
        l0 = l[1].split(/,/,7)
        s_color =  l0[0]
        x1 = l0[1]
        y1 = l0[2]
        x2 = l0[3]
        y2 = l0[4]
        locate = l0[5]
        text = l0[6]
        puts "\\draw[->,color=#{s_color},line width=#{line_width}pt] ({#{x1}},{#{y1}}) -- ({#{x2}},{#{y2}}) node [#{locate}] {#{text}};"
    when "line", "dline"
        l0 = l[1].split(/,/,7)
        s_color = l0[0]
        x1 = l0[1]
        y1 = l0[2]
        x2 = l0[3]
        y2 = l0[4]
        locate = l0[5]
        text = l0[6]
        if l[0] == "line"
            puts "\\draw [color=#{s_color},line width=#{line_width}pt] ({#{x1}},{#{y1}}) -- ({#{x2}},{#{y2}}) node [#{locate}] {#{text}};"
        else
            puts "\\draw [dash pattern=on 3pt off 3pt,color=#{s_color},line width=#{line_width}pt] ({#{x1}},{#{y1}}) -- ({#{x2}},{#{y2}}) node [#{locate}] {#{text}};"
        end
    when "point"
        l0 = l[1].split(/,/,5)
        s_color = l0[0]
        x = l0[1]
        y = l0[2]
        locate = l0[3]
        text = l0[4]
        puts "\\fill [color=#{s_color}] ({#{x}},{#{y}}) circle (#{line_width}pt) node [#{locate}] {#{text}};"
    when "grid"
        l0 = l[1].split(/,/)
        s_color = l0[0]
        step = l0[1]
        x1 = l0[2]
        y1 = l0[3]
        x2 = l0[4]
        y2 = l0[5]
        puts "\\draw[step=#{step},color=#{s_color}] ({#{x1}},{#{y1}}) grid ({#{x2}},{#{y2}});"
    end
end

puts "\\end{tikzpicture}"
puts "\\end{document}"
****

ついでに点の座標もラベルにできるようにする。
変更結果
***
unit 1cm,1cm
range -2,2,-2,2

linewidth 0
plot gray,2,-2,\x,\x,above right,$y=x$

linewidth 1
plot blue,2,0,\x,\x^2-1,right,$y=x^2-1$
linewidth 1.5
point blue,0,-1,left,$(0,-1)$
point blue,1,0,below right,$1$

# 逆関数
linewidth 1
plot red,2,0,\x^2-1,\x,above right,$y=\sqrt{x+1}$
linewidth 1.5
point red,-1,0,below,$-1$
point red,0,1,above left,$1$
***
screenshot1screenshot2

screenshot1


uniti 3cm,3cmとすると
***
unit 3cm,3cm
range -2,2,-2,2

linewidth 0
plot gray,2,-2,\x,\x,above right,$y=x$

linewidth 1
plot blue,2,0,\x,\x^2-1,right,$y=x^2-1$
linewidth 1.5
point blue,0,-1,left,$(0,-1)$
point blue,1,0,below right,$1$

# 逆関数
linewidth 1
plot red,2,0,\x^2-1,\x,above right,$y=\sqrt{x+1}$
linewidth 1.5
point red,-1,0,below,$-1$
point red,0,1,above left,$1$
***
screenshot1

screenshot1

関数y=x^2-1(x≧0)の逆関数のグラフをかき、その定義域を求めよ。 y=x^2-1の逆関数... - Yahoo!知恵袋:

screenshot1

***
unit 1cm,1cm
range -2,2,-2,2

linewidth 0
plot gray,-2,2,\x,\x

linewidth 1
plot blue,0,2,\x,\x^2-1
linewidth 1.5
point blue,0,-1,left,$-1$
point blue,1,0,below right,$1$

# 逆関数
linewidth 1
plot red,0,2,\x^2-1,\x
linewidth 1.5
point red,-1,0,below,$-1$
point red,0,1,above left,$1$
***
screenshot1screenshot2


xとyを入れ替えればいいのでは?

ある関数のグラフの描き方は
flydraw形式では
plot blue,-5,5,\x,sin(\x r)
plot red,-pi,pi,cos(\x r),sin(\x r)

TikZでは
\draw[color=blue, smooth,samples=100,domain={-5}:{5},line width=1.0pt] plot({\x},{sin(\x r)});
\draw[color=red, smooth,samples=100,domain={-pi}:{pi},line width=1.0pt] plot({cos(\x r)},{sin(\x r)});

つまり
関数y=f(x)のグラフは
plot(x座標,y座標)

x座標とy座標を入れ替えて
plot(y座標,x座標)
として描いたグラフが関数y=f(x)の逆関数のグラフでしょう?

***
unit 1cm,.25cm
range -5,5,-20,20
#grid gray,1cm,-5,-20,5,20
#grid gray,1,-5,-20,5,20

linewidth 1
plot blue,-5,5,\x,\x^3-12*\x

linewidth 1.5
point red,-2*sqrt(3),0,above left,$-2\sqrt{3}$
point red,-2,0,below,$-2$
point red,0,0,below left,$O$
point red,2,0,above,$2$
point red,2*sqrt(3),0,below right,$2\sqrt{3}$
point red,0,16,right,$16$
point red,0,-16,left,$-16$

linewidth 0
dline red,-2,0,-2,16
dline red,-2,16,0,16
linewidth 1.5
point red,-2,16

linewidth 0
dline red,2,0,2,-16
dline red,2,-16,0,-16
linewidth 1.5
point red,2,-16

linewidth 0
point black,4.5,0,above,$x軸$
point black,0,18,right,$y軸$
***

screenshot1

grid gray,1,-5,-20,5,20と書いたとき
screenshot1

grid gray,1cm,-5,-20,5,20と書いたとき
screenshot1

オオーw(*゚o゚*)w

        puts "\\fill [color=#{s_color}] ({#{x}},{#{y}}) circle (1.5pt) node [#{locate}] {#{text}};"
これを
        puts "\\fill [color=#{s_color}] ({#{x}},{#{y}}) circle ({#{l_w}}pt) node [#{locate}] {#{text}};"

やっぱり変数の名前 l_wは変えたほうがいいなあ。。。

***
unit 1cm,1cm
range -5,5,-5,5
grid gray,1cm,-5,-5,5,5
linewidth 1.5
point black,0,0,below left,原点

linewidth 10
point black,1,1,below,point10
***
screenshot1

linewidth 0 とすれば、point と textコマンドが同じになる。
screenshot1
なら、textコマンドは削除だな。

ついでに内部の変数 l_wをline_widthに変更。
最新の変換スクリプト
***
line_width = 0

puts "\\documentclass[10pt]{article}"
puts "\\usepackage{pgf,tikz}"
puts
puts "\\usepackage{myjapanese}"
puts "\\usepackage{mypreview}"
puts "\\PreviewEnvironment{tikzpicture}"
puts "\\setlength\\PreviewBorder{5pt}% 余白"
puts
puts "\\usetikzlibrary{arrows}"
puts "\\pagestyle{empty}"
puts "\\begin{document}"

while line = gets
    l = line.chop.split(/\s/,2)
    case l[0]
    when "unit"
        l0 = l[1].split(/,/)
        ux = l0[0]
        uy = l0[1]
puts "\\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=#{ux},y=#{uy}]"
    when "range"
        l0 = l[1].split(/,/)
        x1 = l0[0]
        x2 = l0[1]
        y1 = l0[2]
        y2 = l0[3]
puts "\\draw[->,color=gray] ({#{x1}},{0}) -- ({#{x2}},{0});" # x軸
puts "\\draw[->,color=gray] ({0},{#{y1}}) -- ({0},{#{y2}});" # y軸
puts "\\clip(#{x1},#{y1}) rectangle (#{x2},#{y2});"
    when "linewidth"
        l0 = l[1].split(/,/)
        line_width = l0[0].to_f
    when "plot"
        l0 = l[1].split(/,/)
        s_color =  l0[0]
        d1 = l0[1]
        d2 = l0[2]
        p_f = l0[3]
        p_g = l0[4]
puts "\\draw[color=#{s_color}, smooth,samples=100,domain={#{d1}}:{#{d2}},line width=#{line_width}pt] plot({#{p_f}},{#{p_g}});"
    when "arrow"
        l0 = l[1].split(/,/)
        s_color =  l0[0]
        x1 = l0[1]
        y1 = l0[2]
        x2 = l0[3]
        y2 = l0[4]
        puts "\\draw[->,color=#{s_color},line width=#{line_width}pt] ({#{x1}},{#{y1}}) -- ({#{x2}},{#{y2}});"
    when "line", "dline"
        l0 = l[1].split(/,/)
        s_color = l0[0]
        x1 = l0[1]
        y1 = l0[2]
        x2 = l0[3]
        y2 = l0[4]
        if l[0] == "line"
            puts "\\draw [color=#{s_color},line width=#{line_width}pt] ({#{x1}},{#{y1}}) -- ({#{x2}},{#{y2}});"
        else
            puts "\\draw [dash pattern=on 3pt off 3pt,color=#{s_color},line width=#{line_width}pt] ({#{x1}},{#{y1}}) -- ({#{x2}},{#{y2}});"
        end
    when "point"
        l0 = l[1].split(/,/)
        s_color = l0[0]
        x = l0[1]
        y = l0[2]
        locate = l0[3]
        text = l0[4]
        puts "\\fill [color=#{s_color}] ({#{x}},{#{y}}) circle (#{line_width}pt) node [#{locate}] {#{text}};"
    when "grid"
        l0 = l[1].split(/,/)
        s_color = l0[0]
        step = l0[1]
        x1 = l0[2]
        y1 = l0[3]
        x2 = l0[4]
        y2 = l0[5]
        puts "\\draw[step=#{step},color=#{s_color}] ({#{x1}},{#{y1}}) grid ({#{x2}},{#{y2}});"
    end
end

puts "\\end{tikzpicture}"
puts "\\end{document}"
***

ソース
***
l_w = 0

puts "\\documentclass[10pt]{article}"
puts "\\usepackage{pgf,tikz}"
puts
puts "\\usepackage{myjapanese}"
puts "\\usepackage{mypreview}"
puts "\\PreviewEnvironment{tikzpicture}"
puts "\\setlength\\PreviewBorder{5pt}% 余白"
puts
puts "\\usetikzlibrary{arrows}"
puts "\\pagestyle{empty}"
puts "\\begin{document}"

while line = gets
    l = line.chop.split(/\s/,2)
    case l[0]
    when "unit"
        l0 = l[1].split(/,/)
        ux = l0[0]
        uy = l0[1]
puts "\\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=#{ux},y=#{uy}]"
    when "range"
        l0 = l[1].split(/,/)
        x1 = l0[0]
        x2 = l0[1]
        y1 = l0[2]
        y2 = l0[3]
puts "\\draw[->,color=gray] ({#{x1}},{0}) -- ({#{x2}},{0});" # x軸
puts "\\draw[->,color=gray] ({0},{#{y1}}) -- ({0},{#{y2}});" # y軸
puts "\\clip(#{x1},#{y1}) rectangle (#{x2},#{y2});"
    when "linewidth"
        l0 = l[1].split(/,/)
        l_w = l0[0].to_f
    when "plot"
        l0 = l[1].split(/,/)
        s_color =  l0[0]
        d1 = l0[1]
        d2 = l0[2]
        p_f = l0[3]
        p_g = l0[4]
puts "\\draw[color=#{s_color}, smooth,samples=100,domain={#{d1}}:{#{d2}},line width=#{l_w}pt] plot({#{p_f}},{#{p_g}});"
    when "arrow"
        l0 = l[1].split(/,/)
        s_color =  l0[0]
        x1 = l0[1]
        y1 = l0[2]
        x2 = l0[3]
        y2 = l0[4]
        puts "\\draw[->,color=#{s_color},line width=#{l_w}pt] ({#{x1}},{#{y1}}) -- ({#{x2}},{#{y2}});"
    when "line", "dline"
        l0 = l[1].split(/,/)
        s_color = l0[0]
        x1 = l0[1]
        y1 = l0[2]
        x2 = l0[3]
        y2 = l0[4]
        if l[0] == "line"
            puts "\\draw [color=#{s_color},line width=#{l_w}pt] ({#{x1}},{#{y1}}) -- ({#{x2}},{#{y2}});"
        else
            puts "\\draw [dash pattern=on 3pt off 3pt,color=#{s_color},line width=#{l_w}pt] ({#{x1}},{#{y1}}) -- ({#{x2}},{#{y2}});"
        end
    when "point"
        l0 = l[1].split(/,/)
        s_color = l0[0]
        x = l0[1]
        y = l0[2]
        locate = l0[3]
        text = l0[4]
        puts "\\fill [color=#{s_color}] ({#{x}},{#{y}}) circle (1.5pt) node [#{locate}] {#{text}};"
    when "text"
        l0 = l[1].split(/,/)
        s_color = l0[0]
        x = l0[1]
        y = l0[2]
        locate = l0[3]
        text = l0[4]
        puts "\\draw[color=#{s_color}] ({#{x}},{#{y}}) node [#{locate}] {#{text}};"
    when "grid"
        l0 = l[1].split(/,/)
        s_color = l0[0]
        step = l0[1]
        x1 = l0[2]
        y1 = l0[3]
        x2 = l0[4]
        y2 = l0[5]
        puts "\\draw[step=#{step},color=#{s_color}] ({#{x1}},{#{y1}}) grid ({#{x2}},{#{y2}});"
    end
end

puts "\\end{tikzpicture}"
puts "\\end{document}"
***

コマンドファイル
***
unit 1cm,1cm
range -5,5,-1.5,1.5
grid gray,1cm,-5,-1.5,5,5,1.5
linewidth 1
plot blue,-5,5,\x,sin(\x r)
plot red,-pi,pi,cos(\x r),sin(\x r)

dline red,-pi/2,0,-pi/2,-1
dline red,-pi/2,-1,0,-1
dline red,pi/2,0,pi/2,1
dline red,pi/2,1,0,1

point red,-pi/2,-1,,
point red,pi/2,1,,
point red,-pi/2,0,above,$-\pi/2$
point red,-pi,0,below left,$-\pi$
point red,-pi/2,0,above,$-\pi/2$
point red,0,0,below right,$O$
point red,pi/2,0,below,$\pi/2$
point red,pi,0,above right,$\pi$

text black,4.5,0,above,\small $x軸$
text black,0,1.3,right,\small $y軸$
text black,-4,1,above right,\large\fontspec{ふい字} 三角関数と円
text blue,-4,1,below right,$y=\sin x$
text red,0,-1,below,$x^2+y^2=1$

linewidth 2
arrow green!50!black,-5,-1,-4,0
line orange!80!black,-4,-1,-5,0
***

実行結果
screenshot1

TeX
***
\documentclass[10pt]{article}
\usepackage{pgf,tikz}

\usepackage{myjapanese}
\usepackage{mypreview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}% 余白

\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\draw[->,color=gray] ({-5},{0}) -- ({5},{0});
\draw[->,color=gray] ({0},{-1.5}) -- ({0},{1.5});
\clip(-5,-1.5) rectangle (5,1.5);
\draw[step=1cm,color=gray] ({-5},{-1.5}) grid ({5},{5});
\draw[color=blue, smooth,samples=100,domain={-5}:{5},line width=1.0pt] plot({\x},{sin(\x r)});
\draw[color=red, smooth,samples=100,domain={-pi}:{pi},line width=1.0pt] plot({cos(\x r)},{sin(\x r)});
\draw [dash pattern=on 3pt off 3pt,color=red,line width=1.0pt] ({-pi/2},{0}) -- ({-pi/2},{-1});
\draw [dash pattern=on 3pt off 3pt,color=red,line width=1.0pt] ({-pi/2},{-1}) -- ({0},{-1});
\draw [dash pattern=on 3pt off 3pt,color=red,line width=1.0pt] ({pi/2},{0}) -- ({pi/2},{1});
\draw [dash pattern=on 3pt off 3pt,color=red,line width=1.0pt] ({pi/2},{1}) -- ({0},{1});
\fill [color=red] ({-pi/2},{-1}) circle (1.5pt) node [] {};
\fill [color=red] ({pi/2},{1}) circle (1.5pt) node [] {};
\fill [color=red] ({-pi/2},{0}) circle (1.5pt) node [above] {$-\pi/2$};
\fill [color=red] ({-pi},{0}) circle (1.5pt) node [below left] {$-\pi$};
\fill [color=red] ({-pi/2},{0}) circle (1.5pt) node [above] {$-\pi/2$};
\fill [color=red] ({0},{0}) circle (1.5pt) node [below right] {$O$};
\fill [color=red] ({pi/2},{0}) circle (1.5pt) node [below] {$\pi/2$};
\fill [color=red] ({pi},{0}) circle (1.5pt) node [above right] {$\pi$};
\draw[color=black] ({4.5},{0}) node [above] {\small $x軸$};
\draw[color=black] ({0},{1.3}) node [right] {\small $y軸$};
\draw[color=black] ({-4},{1}) node [above right] {\large\fontspec{ふい字} 三角関数と円};
\draw[color=blue] ({-4},{1}) node [below right] {$y=\sin x$};
\draw[color=red] ({0},{-1}) node [below] {$x^2+y^2=1$};
\draw[->,color=green!50!black,line width=2.0pt] ({-5},{-1}) -- ({-4},{0});
\draw [color=orange!80!black,line width=2.0pt] ({-4},{-1}) -- ({-5},{0});
\end{tikzpicture}
\end{document}
***

このページのトップヘ