Trying to make a 3dplot












5















I'm trying to make 3d plot. Unfortunately, I can't succeed in getting the desired figure, as shown below.



Here is the figure, where it's a sphere have a charge of -1 inside. And coordinate axes are supposed to be blur inside the sphere may not be dashed.
enter image description here
Still a MWE:



%% Copyright 2009 Jeffrey D. Hein
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Jeffrey D. Hein.
%
% This work consists of the files 3dplot.sty and 3dplot.tex

%Description
%-----------
%3dplot.tex - an example file demonstrating the use of the 3dplot.sty package.

%Created 2009-11-07 by Jeff Hein. Last updated: 2009-11-09
%----------------------------------------------------------

%Update Notes
%------------

%2009-11-07: Created file along with 3dplot.sty package


documentclass{article}
usepackage{tikz} %TikZ is required for this to work. Make sure this exists before the next line

usepackage{3dplot} %requires 3dplot.sty to be in same directory, or in your LaTeX installation

usepackage[active,tightpage]{preview} %generates a tightly fitting border around the work
PreviewEnvironment{tikzpicture}
setlengthPreviewBorder{2mm}

begin{document}

%Angle Definitions
%-----------------

%set the plot display orientation
%synatax: tdplotsetdisplay{theta_d}{phi_d}
tdplotsetmaincoords{45}{135}

%define polar coordinates for some vector
%TODO: look into using 3d spherical coordinate system
pgfmathsetmacro{rvec}{.8}
pgfmathsetmacro{thetavec}{45}
pgfmathsetmacro{phivec}{60}

%start tikz picture, and use the tdplot_main_coords style to implement the display
%coordinate transformation provided by 3dplot
begin{tikzpicture}[scale=5,tdplot_main_coords]

% Teken eerst de bol
shade[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);

%set up some coordinates
%-----------------------
coordinate (O) at (0,0,0);

%determine a coordinate (P) using (r,theta,phi) coordinates. This command
%also determines (Pxy), (Pxz), and (Pyz): the xy-, xz-, and yz-projections
%of the point (P).
%syntax: tdplotsetcoord{Coordinate name without parentheses}{r}{theta}{phi}
tdplotsetcoord{P}{rvec}{thetavec}{phivec}

%draw figure contents
%--------------------

%draw the main coordinate system axes
draw[thick,->] (0,0,0) -- (-1.5,0,0)-- (1.5,0,0) node[anchor=north east]{$x$};
draw[thick,->] (0,0,0) -- (0,-1.5,0)--(0,1.5,0) node[anchor=north west]{$y$};
draw[thick,->] (0,0,-1) -- (0,0,-1.5)-- (0,0,1.5) node[anchor=south]{$z$};





end{tikzpicture}

end{document}


Edited image:
enter image description here










share|improve this question





























    5















    I'm trying to make 3d plot. Unfortunately, I can't succeed in getting the desired figure, as shown below.



    Here is the figure, where it's a sphere have a charge of -1 inside. And coordinate axes are supposed to be blur inside the sphere may not be dashed.
    enter image description here
    Still a MWE:



    %% Copyright 2009 Jeffrey D. Hein
    %
    % This work may be distributed and/or modified under the
    % conditions of the LaTeX Project Public License, either version 1.3
    % of this license or (at your option) any later version.
    % The latest version of this license is in
    % http://www.latex-project.org/lppl.txt
    % and version 1.3 or later is part of all distributions of LaTeX
    % version 2005/12/01 or later.
    %
    % This work has the LPPL maintenance status `maintained'.
    %
    % The Current Maintainer of this work is Jeffrey D. Hein.
    %
    % This work consists of the files 3dplot.sty and 3dplot.tex

    %Description
    %-----------
    %3dplot.tex - an example file demonstrating the use of the 3dplot.sty package.

    %Created 2009-11-07 by Jeff Hein. Last updated: 2009-11-09
    %----------------------------------------------------------

    %Update Notes
    %------------

    %2009-11-07: Created file along with 3dplot.sty package


    documentclass{article}
    usepackage{tikz} %TikZ is required for this to work. Make sure this exists before the next line

    usepackage{3dplot} %requires 3dplot.sty to be in same directory, or in your LaTeX installation

    usepackage[active,tightpage]{preview} %generates a tightly fitting border around the work
    PreviewEnvironment{tikzpicture}
    setlengthPreviewBorder{2mm}

    begin{document}

    %Angle Definitions
    %-----------------

    %set the plot display orientation
    %synatax: tdplotsetdisplay{theta_d}{phi_d}
    tdplotsetmaincoords{45}{135}

    %define polar coordinates for some vector
    %TODO: look into using 3d spherical coordinate system
    pgfmathsetmacro{rvec}{.8}
    pgfmathsetmacro{thetavec}{45}
    pgfmathsetmacro{phivec}{60}

    %start tikz picture, and use the tdplot_main_coords style to implement the display
    %coordinate transformation provided by 3dplot
    begin{tikzpicture}[scale=5,tdplot_main_coords]

    % Teken eerst de bol
    shade[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);

    %set up some coordinates
    %-----------------------
    coordinate (O) at (0,0,0);

    %determine a coordinate (P) using (r,theta,phi) coordinates. This command
    %also determines (Pxy), (Pxz), and (Pyz): the xy-, xz-, and yz-projections
    %of the point (P).
    %syntax: tdplotsetcoord{Coordinate name without parentheses}{r}{theta}{phi}
    tdplotsetcoord{P}{rvec}{thetavec}{phivec}

    %draw figure contents
    %--------------------

    %draw the main coordinate system axes
    draw[thick,->] (0,0,0) -- (-1.5,0,0)-- (1.5,0,0) node[anchor=north east]{$x$};
    draw[thick,->] (0,0,0) -- (0,-1.5,0)--(0,1.5,0) node[anchor=north west]{$y$};
    draw[thick,->] (0,0,-1) -- (0,0,-1.5)-- (0,0,1.5) node[anchor=south]{$z$};





    end{tikzpicture}

    end{document}


    Edited image:
    enter image description here










    share|improve this question



























      5












      5








      5


      2






      I'm trying to make 3d plot. Unfortunately, I can't succeed in getting the desired figure, as shown below.



      Here is the figure, where it's a sphere have a charge of -1 inside. And coordinate axes are supposed to be blur inside the sphere may not be dashed.
      enter image description here
      Still a MWE:



      %% Copyright 2009 Jeffrey D. Hein
      %
      % This work may be distributed and/or modified under the
      % conditions of the LaTeX Project Public License, either version 1.3
      % of this license or (at your option) any later version.
      % The latest version of this license is in
      % http://www.latex-project.org/lppl.txt
      % and version 1.3 or later is part of all distributions of LaTeX
      % version 2005/12/01 or later.
      %
      % This work has the LPPL maintenance status `maintained'.
      %
      % The Current Maintainer of this work is Jeffrey D. Hein.
      %
      % This work consists of the files 3dplot.sty and 3dplot.tex

      %Description
      %-----------
      %3dplot.tex - an example file demonstrating the use of the 3dplot.sty package.

      %Created 2009-11-07 by Jeff Hein. Last updated: 2009-11-09
      %----------------------------------------------------------

      %Update Notes
      %------------

      %2009-11-07: Created file along with 3dplot.sty package


      documentclass{article}
      usepackage{tikz} %TikZ is required for this to work. Make sure this exists before the next line

      usepackage{3dplot} %requires 3dplot.sty to be in same directory, or in your LaTeX installation

      usepackage[active,tightpage]{preview} %generates a tightly fitting border around the work
      PreviewEnvironment{tikzpicture}
      setlengthPreviewBorder{2mm}

      begin{document}

      %Angle Definitions
      %-----------------

      %set the plot display orientation
      %synatax: tdplotsetdisplay{theta_d}{phi_d}
      tdplotsetmaincoords{45}{135}

      %define polar coordinates for some vector
      %TODO: look into using 3d spherical coordinate system
      pgfmathsetmacro{rvec}{.8}
      pgfmathsetmacro{thetavec}{45}
      pgfmathsetmacro{phivec}{60}

      %start tikz picture, and use the tdplot_main_coords style to implement the display
      %coordinate transformation provided by 3dplot
      begin{tikzpicture}[scale=5,tdplot_main_coords]

      % Teken eerst de bol
      shade[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);

      %set up some coordinates
      %-----------------------
      coordinate (O) at (0,0,0);

      %determine a coordinate (P) using (r,theta,phi) coordinates. This command
      %also determines (Pxy), (Pxz), and (Pyz): the xy-, xz-, and yz-projections
      %of the point (P).
      %syntax: tdplotsetcoord{Coordinate name without parentheses}{r}{theta}{phi}
      tdplotsetcoord{P}{rvec}{thetavec}{phivec}

      %draw figure contents
      %--------------------

      %draw the main coordinate system axes
      draw[thick,->] (0,0,0) -- (-1.5,0,0)-- (1.5,0,0) node[anchor=north east]{$x$};
      draw[thick,->] (0,0,0) -- (0,-1.5,0)--(0,1.5,0) node[anchor=north west]{$y$};
      draw[thick,->] (0,0,-1) -- (0,0,-1.5)-- (0,0,1.5) node[anchor=south]{$z$};





      end{tikzpicture}

      end{document}


      Edited image:
      enter image description here










      share|improve this question
















      I'm trying to make 3d plot. Unfortunately, I can't succeed in getting the desired figure, as shown below.



      Here is the figure, where it's a sphere have a charge of -1 inside. And coordinate axes are supposed to be blur inside the sphere may not be dashed.
      enter image description here
      Still a MWE:



      %% Copyright 2009 Jeffrey D. Hein
      %
      % This work may be distributed and/or modified under the
      % conditions of the LaTeX Project Public License, either version 1.3
      % of this license or (at your option) any later version.
      % The latest version of this license is in
      % http://www.latex-project.org/lppl.txt
      % and version 1.3 or later is part of all distributions of LaTeX
      % version 2005/12/01 or later.
      %
      % This work has the LPPL maintenance status `maintained'.
      %
      % The Current Maintainer of this work is Jeffrey D. Hein.
      %
      % This work consists of the files 3dplot.sty and 3dplot.tex

      %Description
      %-----------
      %3dplot.tex - an example file demonstrating the use of the 3dplot.sty package.

      %Created 2009-11-07 by Jeff Hein. Last updated: 2009-11-09
      %----------------------------------------------------------

      %Update Notes
      %------------

      %2009-11-07: Created file along with 3dplot.sty package


      documentclass{article}
      usepackage{tikz} %TikZ is required for this to work. Make sure this exists before the next line

      usepackage{3dplot} %requires 3dplot.sty to be in same directory, or in your LaTeX installation

      usepackage[active,tightpage]{preview} %generates a tightly fitting border around the work
      PreviewEnvironment{tikzpicture}
      setlengthPreviewBorder{2mm}

      begin{document}

      %Angle Definitions
      %-----------------

      %set the plot display orientation
      %synatax: tdplotsetdisplay{theta_d}{phi_d}
      tdplotsetmaincoords{45}{135}

      %define polar coordinates for some vector
      %TODO: look into using 3d spherical coordinate system
      pgfmathsetmacro{rvec}{.8}
      pgfmathsetmacro{thetavec}{45}
      pgfmathsetmacro{phivec}{60}

      %start tikz picture, and use the tdplot_main_coords style to implement the display
      %coordinate transformation provided by 3dplot
      begin{tikzpicture}[scale=5,tdplot_main_coords]

      % Teken eerst de bol
      shade[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);

      %set up some coordinates
      %-----------------------
      coordinate (O) at (0,0,0);

      %determine a coordinate (P) using (r,theta,phi) coordinates. This command
      %also determines (Pxy), (Pxz), and (Pyz): the xy-, xz-, and yz-projections
      %of the point (P).
      %syntax: tdplotsetcoord{Coordinate name without parentheses}{r}{theta}{phi}
      tdplotsetcoord{P}{rvec}{thetavec}{phivec}

      %draw figure contents
      %--------------------

      %draw the main coordinate system axes
      draw[thick,->] (0,0,0) -- (-1.5,0,0)-- (1.5,0,0) node[anchor=north east]{$x$};
      draw[thick,->] (0,0,0) -- (0,-1.5,0)--(0,1.5,0) node[anchor=north west]{$y$};
      draw[thick,->] (0,0,-1) -- (0,0,-1.5)-- (0,0,1.5) node[anchor=south]{$z$};





      end{tikzpicture}

      end{document}


      Edited image:
      enter image description here







      tikz-pgf






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 22 at 13:01







      Shamina

















      asked Feb 22 at 11:05









      ShaminaShamina

      447213




      447213






















          2 Answers
          2






          active

          oldest

          votes


















          9














          Based on tikz-3dplot package definitions.



          documentclass{article}
          usepackage{tikz}
          usepackage{tikz-3dplot}

          begin{document}

          %Angle Definitions
          %-----------------

          %set the plot display orientation
          %syntax: tdplotsetdisplay{theta_d}{phi_d}
          tdplotsetmaincoords{65}{110}
          pgfmathsetmacro{rvec}{1}
          pgfmathsetmacro{thetavecc}{55}
          pgfmathsetmacro{phivecc}{35}
          pgfmathsetmacro{thetaveccc}{39.7}
          pgfmathsetmacro{phiveccc}{55}

          begin{tikzpicture}[scale=5,tdplot_main_coords,>=latex]

          shadedraw[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);
          node[tdplot_screen_coords,xshift=1cm,yshift=3mm] (0,0) {$q=-1$};

          defh{1}

          %-----------------------
          coordinate (O) at (0,0,0);

          %draw the main coordinate system axes
          draw[thick,opacity=0.5] (0,0,0) -- (1,0,0);
          draw[thick,opacity=0.5] (0,0,0) -- (0,1,0);
          draw[thick,opacity=0.5] (0,0,0) -- (0,0,1);
          draw[thick,->] (1,0,0) -- (2.3,0,0) node[anchor=north east]{$x$};
          draw[thick,->] (0,1,0) -- (0,1.5,0) node[anchor=north west]{$y$};
          draw[thick,->] (0,0,1) -- (0,0,1.5) node[anchor=south]{$z$};

          % Equator
          draw[dashed] (rvec,0,0) arc (0:360:rvec);
          draw[thick] (rvec,0,0) arc (0:110:rvec);
          draw[thick] (rvec,0,0) arc (0:-70:rvec);

          % Flux arrows
          foreach t in {10,20,...,340}
          foreach f in {180,170,...,0}
          draw [black!60,opacity=1.0, <-, thick]
          ({sin(f - h)*cos(t - h)}, {sin(f - h)*sin(t - h)}, {cos(f - h)})
          -- ({(1 + 0.2*cos(90 - f))*sin(f - h)*cos(t - h)},
          {(1 + 0.2*cos(90 - f))*sin(f - h)*sin(t - h)},
          {(1 + 0.2*cos(90 - f))*cos(f - h)});

          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer


























          • Thanks! Is there a way to decrease the intensity of the arrows? Also maybe the color of the sphere?

            – Shamina
            Feb 22 at 13:05






          • 1





            @Shamina, your welcome. To decrease the intensity of the arrows, change the increment or decrement of the foreach loops in Flux arrows definitions. For example foreach t in {10,30,...,340} and so on. For color of sphere, insert opacitiy key in shadedraw. For example, shadedraw[tdplot_screen_coords,ball color = white,opacity=0.5] (0,0) circle (rvec);

            – ferahfeza
            Feb 22 at 13:18











          • Just one last question, what decides the length of arrows?

            – Shamina
            Feb 22 at 16:31











          • In flux arrows section, change the multiplier of cos, say (1 + 0.5*cos(90 - f)).

            – ferahfeza
            Feb 22 at 16:56






          • 1





            This is a very nice answer, +1. May I suggest to draw the thing in 3 steps? 1. arrows in the background. 2. Sphere. 3. Arrows in the foreground.

            – marmot
            Feb 22 at 17:29



















          4














          The following code does draw the sphere (above the axes to hide them) and the -1. It uses tikz-3dplot which is in TeX Live.



          with flux arrows



          documentclass[tikz]{standalone}
          usepackage{tikz-3dplot}

          begin{document}
          tdplotsetmaincoords{60}{135}

          pgfmathsetmacro{rvec}{.8}

          begin{tikzpicture}[scale=5,tdplot_main_coords]
          coordinate (O) at (0,0,0);

          draw[thick,->] (-1.5,0,0)-- (1.5,0,0) node[anchor=north east]{$x$};
          draw[thick,->] (0,-1.5,0)--(0,1.5,0) node[anchor=north west]{$y$};
          draw[thick,->] (0,0,-1.5)-- (0,0,1.5) node[anchor=south]{$z$};

          shade[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);

          foreach i in {0,20,...,360}
          draw[tdplot_screen_coords,<-] (i:.9*rvec) -- (i: 1.1*rvec);

          node[tdplot_screen_coords] (0,0) {$-1$};
          end{tikzpicture}
          end{document}





          share|improve this answer


























          • Thanks a lot! Is there a way to get those flux arrows(pointing inside the sphere) also? Is there a way to get an equator? Also the axes to be seen but bit blur inside the sphere?

            – Shamina
            Feb 22 at 11:40













          • @Shamina I have added some arrows. Could you please edit your question to make the other requirements more clear (which type of blurring do you refer to and where do you want the equator to be)?

            – TeXnician
            Feb 22 at 11:48











          • I edited my answer. I mean blurring inside the sphere

            – Shamina
            Feb 22 at 13:02











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476138%2ftrying-to-make-a-3dplot%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          9














          Based on tikz-3dplot package definitions.



          documentclass{article}
          usepackage{tikz}
          usepackage{tikz-3dplot}

          begin{document}

          %Angle Definitions
          %-----------------

          %set the plot display orientation
          %syntax: tdplotsetdisplay{theta_d}{phi_d}
          tdplotsetmaincoords{65}{110}
          pgfmathsetmacro{rvec}{1}
          pgfmathsetmacro{thetavecc}{55}
          pgfmathsetmacro{phivecc}{35}
          pgfmathsetmacro{thetaveccc}{39.7}
          pgfmathsetmacro{phiveccc}{55}

          begin{tikzpicture}[scale=5,tdplot_main_coords,>=latex]

          shadedraw[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);
          node[tdplot_screen_coords,xshift=1cm,yshift=3mm] (0,0) {$q=-1$};

          defh{1}

          %-----------------------
          coordinate (O) at (0,0,0);

          %draw the main coordinate system axes
          draw[thick,opacity=0.5] (0,0,0) -- (1,0,0);
          draw[thick,opacity=0.5] (0,0,0) -- (0,1,0);
          draw[thick,opacity=0.5] (0,0,0) -- (0,0,1);
          draw[thick,->] (1,0,0) -- (2.3,0,0) node[anchor=north east]{$x$};
          draw[thick,->] (0,1,0) -- (0,1.5,0) node[anchor=north west]{$y$};
          draw[thick,->] (0,0,1) -- (0,0,1.5) node[anchor=south]{$z$};

          % Equator
          draw[dashed] (rvec,0,0) arc (0:360:rvec);
          draw[thick] (rvec,0,0) arc (0:110:rvec);
          draw[thick] (rvec,0,0) arc (0:-70:rvec);

          % Flux arrows
          foreach t in {10,20,...,340}
          foreach f in {180,170,...,0}
          draw [black!60,opacity=1.0, <-, thick]
          ({sin(f - h)*cos(t - h)}, {sin(f - h)*sin(t - h)}, {cos(f - h)})
          -- ({(1 + 0.2*cos(90 - f))*sin(f - h)*cos(t - h)},
          {(1 + 0.2*cos(90 - f))*sin(f - h)*sin(t - h)},
          {(1 + 0.2*cos(90 - f))*cos(f - h)});

          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer


























          • Thanks! Is there a way to decrease the intensity of the arrows? Also maybe the color of the sphere?

            – Shamina
            Feb 22 at 13:05






          • 1





            @Shamina, your welcome. To decrease the intensity of the arrows, change the increment or decrement of the foreach loops in Flux arrows definitions. For example foreach t in {10,30,...,340} and so on. For color of sphere, insert opacitiy key in shadedraw. For example, shadedraw[tdplot_screen_coords,ball color = white,opacity=0.5] (0,0) circle (rvec);

            – ferahfeza
            Feb 22 at 13:18











          • Just one last question, what decides the length of arrows?

            – Shamina
            Feb 22 at 16:31











          • In flux arrows section, change the multiplier of cos, say (1 + 0.5*cos(90 - f)).

            – ferahfeza
            Feb 22 at 16:56






          • 1





            This is a very nice answer, +1. May I suggest to draw the thing in 3 steps? 1. arrows in the background. 2. Sphere. 3. Arrows in the foreground.

            – marmot
            Feb 22 at 17:29
















          9














          Based on tikz-3dplot package definitions.



          documentclass{article}
          usepackage{tikz}
          usepackage{tikz-3dplot}

          begin{document}

          %Angle Definitions
          %-----------------

          %set the plot display orientation
          %syntax: tdplotsetdisplay{theta_d}{phi_d}
          tdplotsetmaincoords{65}{110}
          pgfmathsetmacro{rvec}{1}
          pgfmathsetmacro{thetavecc}{55}
          pgfmathsetmacro{phivecc}{35}
          pgfmathsetmacro{thetaveccc}{39.7}
          pgfmathsetmacro{phiveccc}{55}

          begin{tikzpicture}[scale=5,tdplot_main_coords,>=latex]

          shadedraw[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);
          node[tdplot_screen_coords,xshift=1cm,yshift=3mm] (0,0) {$q=-1$};

          defh{1}

          %-----------------------
          coordinate (O) at (0,0,0);

          %draw the main coordinate system axes
          draw[thick,opacity=0.5] (0,0,0) -- (1,0,0);
          draw[thick,opacity=0.5] (0,0,0) -- (0,1,0);
          draw[thick,opacity=0.5] (0,0,0) -- (0,0,1);
          draw[thick,->] (1,0,0) -- (2.3,0,0) node[anchor=north east]{$x$};
          draw[thick,->] (0,1,0) -- (0,1.5,0) node[anchor=north west]{$y$};
          draw[thick,->] (0,0,1) -- (0,0,1.5) node[anchor=south]{$z$};

          % Equator
          draw[dashed] (rvec,0,0) arc (0:360:rvec);
          draw[thick] (rvec,0,0) arc (0:110:rvec);
          draw[thick] (rvec,0,0) arc (0:-70:rvec);

          % Flux arrows
          foreach t in {10,20,...,340}
          foreach f in {180,170,...,0}
          draw [black!60,opacity=1.0, <-, thick]
          ({sin(f - h)*cos(t - h)}, {sin(f - h)*sin(t - h)}, {cos(f - h)})
          -- ({(1 + 0.2*cos(90 - f))*sin(f - h)*cos(t - h)},
          {(1 + 0.2*cos(90 - f))*sin(f - h)*sin(t - h)},
          {(1 + 0.2*cos(90 - f))*cos(f - h)});

          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer


























          • Thanks! Is there a way to decrease the intensity of the arrows? Also maybe the color of the sphere?

            – Shamina
            Feb 22 at 13:05






          • 1





            @Shamina, your welcome. To decrease the intensity of the arrows, change the increment or decrement of the foreach loops in Flux arrows definitions. For example foreach t in {10,30,...,340} and so on. For color of sphere, insert opacitiy key in shadedraw. For example, shadedraw[tdplot_screen_coords,ball color = white,opacity=0.5] (0,0) circle (rvec);

            – ferahfeza
            Feb 22 at 13:18











          • Just one last question, what decides the length of arrows?

            – Shamina
            Feb 22 at 16:31











          • In flux arrows section, change the multiplier of cos, say (1 + 0.5*cos(90 - f)).

            – ferahfeza
            Feb 22 at 16:56






          • 1





            This is a very nice answer, +1. May I suggest to draw the thing in 3 steps? 1. arrows in the background. 2. Sphere. 3. Arrows in the foreground.

            – marmot
            Feb 22 at 17:29














          9












          9








          9







          Based on tikz-3dplot package definitions.



          documentclass{article}
          usepackage{tikz}
          usepackage{tikz-3dplot}

          begin{document}

          %Angle Definitions
          %-----------------

          %set the plot display orientation
          %syntax: tdplotsetdisplay{theta_d}{phi_d}
          tdplotsetmaincoords{65}{110}
          pgfmathsetmacro{rvec}{1}
          pgfmathsetmacro{thetavecc}{55}
          pgfmathsetmacro{phivecc}{35}
          pgfmathsetmacro{thetaveccc}{39.7}
          pgfmathsetmacro{phiveccc}{55}

          begin{tikzpicture}[scale=5,tdplot_main_coords,>=latex]

          shadedraw[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);
          node[tdplot_screen_coords,xshift=1cm,yshift=3mm] (0,0) {$q=-1$};

          defh{1}

          %-----------------------
          coordinate (O) at (0,0,0);

          %draw the main coordinate system axes
          draw[thick,opacity=0.5] (0,0,0) -- (1,0,0);
          draw[thick,opacity=0.5] (0,0,0) -- (0,1,0);
          draw[thick,opacity=0.5] (0,0,0) -- (0,0,1);
          draw[thick,->] (1,0,0) -- (2.3,0,0) node[anchor=north east]{$x$};
          draw[thick,->] (0,1,0) -- (0,1.5,0) node[anchor=north west]{$y$};
          draw[thick,->] (0,0,1) -- (0,0,1.5) node[anchor=south]{$z$};

          % Equator
          draw[dashed] (rvec,0,0) arc (0:360:rvec);
          draw[thick] (rvec,0,0) arc (0:110:rvec);
          draw[thick] (rvec,0,0) arc (0:-70:rvec);

          % Flux arrows
          foreach t in {10,20,...,340}
          foreach f in {180,170,...,0}
          draw [black!60,opacity=1.0, <-, thick]
          ({sin(f - h)*cos(t - h)}, {sin(f - h)*sin(t - h)}, {cos(f - h)})
          -- ({(1 + 0.2*cos(90 - f))*sin(f - h)*cos(t - h)},
          {(1 + 0.2*cos(90 - f))*sin(f - h)*sin(t - h)},
          {(1 + 0.2*cos(90 - f))*cos(f - h)});

          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer















          Based on tikz-3dplot package definitions.



          documentclass{article}
          usepackage{tikz}
          usepackage{tikz-3dplot}

          begin{document}

          %Angle Definitions
          %-----------------

          %set the plot display orientation
          %syntax: tdplotsetdisplay{theta_d}{phi_d}
          tdplotsetmaincoords{65}{110}
          pgfmathsetmacro{rvec}{1}
          pgfmathsetmacro{thetavecc}{55}
          pgfmathsetmacro{phivecc}{35}
          pgfmathsetmacro{thetaveccc}{39.7}
          pgfmathsetmacro{phiveccc}{55}

          begin{tikzpicture}[scale=5,tdplot_main_coords,>=latex]

          shadedraw[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);
          node[tdplot_screen_coords,xshift=1cm,yshift=3mm] (0,0) {$q=-1$};

          defh{1}

          %-----------------------
          coordinate (O) at (0,0,0);

          %draw the main coordinate system axes
          draw[thick,opacity=0.5] (0,0,0) -- (1,0,0);
          draw[thick,opacity=0.5] (0,0,0) -- (0,1,0);
          draw[thick,opacity=0.5] (0,0,0) -- (0,0,1);
          draw[thick,->] (1,0,0) -- (2.3,0,0) node[anchor=north east]{$x$};
          draw[thick,->] (0,1,0) -- (0,1.5,0) node[anchor=north west]{$y$};
          draw[thick,->] (0,0,1) -- (0,0,1.5) node[anchor=south]{$z$};

          % Equator
          draw[dashed] (rvec,0,0) arc (0:360:rvec);
          draw[thick] (rvec,0,0) arc (0:110:rvec);
          draw[thick] (rvec,0,0) arc (0:-70:rvec);

          % Flux arrows
          foreach t in {10,20,...,340}
          foreach f in {180,170,...,0}
          draw [black!60,opacity=1.0, <-, thick]
          ({sin(f - h)*cos(t - h)}, {sin(f - h)*sin(t - h)}, {cos(f - h)})
          -- ({(1 + 0.2*cos(90 - f))*sin(f - h)*cos(t - h)},
          {(1 + 0.2*cos(90 - f))*sin(f - h)*sin(t - h)},
          {(1 + 0.2*cos(90 - f))*cos(f - h)});

          end{tikzpicture}
          end{document}


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 11 at 22:09

























          answered Feb 22 at 12:46









          ferahfezaferahfeza

          7,07911933




          7,07911933













          • Thanks! Is there a way to decrease the intensity of the arrows? Also maybe the color of the sphere?

            – Shamina
            Feb 22 at 13:05






          • 1





            @Shamina, your welcome. To decrease the intensity of the arrows, change the increment or decrement of the foreach loops in Flux arrows definitions. For example foreach t in {10,30,...,340} and so on. For color of sphere, insert opacitiy key in shadedraw. For example, shadedraw[tdplot_screen_coords,ball color = white,opacity=0.5] (0,0) circle (rvec);

            – ferahfeza
            Feb 22 at 13:18











          • Just one last question, what decides the length of arrows?

            – Shamina
            Feb 22 at 16:31











          • In flux arrows section, change the multiplier of cos, say (1 + 0.5*cos(90 - f)).

            – ferahfeza
            Feb 22 at 16:56






          • 1





            This is a very nice answer, +1. May I suggest to draw the thing in 3 steps? 1. arrows in the background. 2. Sphere. 3. Arrows in the foreground.

            – marmot
            Feb 22 at 17:29



















          • Thanks! Is there a way to decrease the intensity of the arrows? Also maybe the color of the sphere?

            – Shamina
            Feb 22 at 13:05






          • 1





            @Shamina, your welcome. To decrease the intensity of the arrows, change the increment or decrement of the foreach loops in Flux arrows definitions. For example foreach t in {10,30,...,340} and so on. For color of sphere, insert opacitiy key in shadedraw. For example, shadedraw[tdplot_screen_coords,ball color = white,opacity=0.5] (0,0) circle (rvec);

            – ferahfeza
            Feb 22 at 13:18











          • Just one last question, what decides the length of arrows?

            – Shamina
            Feb 22 at 16:31











          • In flux arrows section, change the multiplier of cos, say (1 + 0.5*cos(90 - f)).

            – ferahfeza
            Feb 22 at 16:56






          • 1





            This is a very nice answer, +1. May I suggest to draw the thing in 3 steps? 1. arrows in the background. 2. Sphere. 3. Arrows in the foreground.

            – marmot
            Feb 22 at 17:29

















          Thanks! Is there a way to decrease the intensity of the arrows? Also maybe the color of the sphere?

          – Shamina
          Feb 22 at 13:05





          Thanks! Is there a way to decrease the intensity of the arrows? Also maybe the color of the sphere?

          – Shamina
          Feb 22 at 13:05




          1




          1





          @Shamina, your welcome. To decrease the intensity of the arrows, change the increment or decrement of the foreach loops in Flux arrows definitions. For example foreach t in {10,30,...,340} and so on. For color of sphere, insert opacitiy key in shadedraw. For example, shadedraw[tdplot_screen_coords,ball color = white,opacity=0.5] (0,0) circle (rvec);

          – ferahfeza
          Feb 22 at 13:18





          @Shamina, your welcome. To decrease the intensity of the arrows, change the increment or decrement of the foreach loops in Flux arrows definitions. For example foreach t in {10,30,...,340} and so on. For color of sphere, insert opacitiy key in shadedraw. For example, shadedraw[tdplot_screen_coords,ball color = white,opacity=0.5] (0,0) circle (rvec);

          – ferahfeza
          Feb 22 at 13:18













          Just one last question, what decides the length of arrows?

          – Shamina
          Feb 22 at 16:31





          Just one last question, what decides the length of arrows?

          – Shamina
          Feb 22 at 16:31













          In flux arrows section, change the multiplier of cos, say (1 + 0.5*cos(90 - f)).

          – ferahfeza
          Feb 22 at 16:56





          In flux arrows section, change the multiplier of cos, say (1 + 0.5*cos(90 - f)).

          – ferahfeza
          Feb 22 at 16:56




          1




          1





          This is a very nice answer, +1. May I suggest to draw the thing in 3 steps? 1. arrows in the background. 2. Sphere. 3. Arrows in the foreground.

          – marmot
          Feb 22 at 17:29





          This is a very nice answer, +1. May I suggest to draw the thing in 3 steps? 1. arrows in the background. 2. Sphere. 3. Arrows in the foreground.

          – marmot
          Feb 22 at 17:29











          4














          The following code does draw the sphere (above the axes to hide them) and the -1. It uses tikz-3dplot which is in TeX Live.



          with flux arrows



          documentclass[tikz]{standalone}
          usepackage{tikz-3dplot}

          begin{document}
          tdplotsetmaincoords{60}{135}

          pgfmathsetmacro{rvec}{.8}

          begin{tikzpicture}[scale=5,tdplot_main_coords]
          coordinate (O) at (0,0,0);

          draw[thick,->] (-1.5,0,0)-- (1.5,0,0) node[anchor=north east]{$x$};
          draw[thick,->] (0,-1.5,0)--(0,1.5,0) node[anchor=north west]{$y$};
          draw[thick,->] (0,0,-1.5)-- (0,0,1.5) node[anchor=south]{$z$};

          shade[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);

          foreach i in {0,20,...,360}
          draw[tdplot_screen_coords,<-] (i:.9*rvec) -- (i: 1.1*rvec);

          node[tdplot_screen_coords] (0,0) {$-1$};
          end{tikzpicture}
          end{document}





          share|improve this answer


























          • Thanks a lot! Is there a way to get those flux arrows(pointing inside the sphere) also? Is there a way to get an equator? Also the axes to be seen but bit blur inside the sphere?

            – Shamina
            Feb 22 at 11:40













          • @Shamina I have added some arrows. Could you please edit your question to make the other requirements more clear (which type of blurring do you refer to and where do you want the equator to be)?

            – TeXnician
            Feb 22 at 11:48











          • I edited my answer. I mean blurring inside the sphere

            – Shamina
            Feb 22 at 13:02
















          4














          The following code does draw the sphere (above the axes to hide them) and the -1. It uses tikz-3dplot which is in TeX Live.



          with flux arrows



          documentclass[tikz]{standalone}
          usepackage{tikz-3dplot}

          begin{document}
          tdplotsetmaincoords{60}{135}

          pgfmathsetmacro{rvec}{.8}

          begin{tikzpicture}[scale=5,tdplot_main_coords]
          coordinate (O) at (0,0,0);

          draw[thick,->] (-1.5,0,0)-- (1.5,0,0) node[anchor=north east]{$x$};
          draw[thick,->] (0,-1.5,0)--(0,1.5,0) node[anchor=north west]{$y$};
          draw[thick,->] (0,0,-1.5)-- (0,0,1.5) node[anchor=south]{$z$};

          shade[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);

          foreach i in {0,20,...,360}
          draw[tdplot_screen_coords,<-] (i:.9*rvec) -- (i: 1.1*rvec);

          node[tdplot_screen_coords] (0,0) {$-1$};
          end{tikzpicture}
          end{document}





          share|improve this answer


























          • Thanks a lot! Is there a way to get those flux arrows(pointing inside the sphere) also? Is there a way to get an equator? Also the axes to be seen but bit blur inside the sphere?

            – Shamina
            Feb 22 at 11:40













          • @Shamina I have added some arrows. Could you please edit your question to make the other requirements more clear (which type of blurring do you refer to and where do you want the equator to be)?

            – TeXnician
            Feb 22 at 11:48











          • I edited my answer. I mean blurring inside the sphere

            – Shamina
            Feb 22 at 13:02














          4












          4








          4







          The following code does draw the sphere (above the axes to hide them) and the -1. It uses tikz-3dplot which is in TeX Live.



          with flux arrows



          documentclass[tikz]{standalone}
          usepackage{tikz-3dplot}

          begin{document}
          tdplotsetmaincoords{60}{135}

          pgfmathsetmacro{rvec}{.8}

          begin{tikzpicture}[scale=5,tdplot_main_coords]
          coordinate (O) at (0,0,0);

          draw[thick,->] (-1.5,0,0)-- (1.5,0,0) node[anchor=north east]{$x$};
          draw[thick,->] (0,-1.5,0)--(0,1.5,0) node[anchor=north west]{$y$};
          draw[thick,->] (0,0,-1.5)-- (0,0,1.5) node[anchor=south]{$z$};

          shade[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);

          foreach i in {0,20,...,360}
          draw[tdplot_screen_coords,<-] (i:.9*rvec) -- (i: 1.1*rvec);

          node[tdplot_screen_coords] (0,0) {$-1$};
          end{tikzpicture}
          end{document}





          share|improve this answer















          The following code does draw the sphere (above the axes to hide them) and the -1. It uses tikz-3dplot which is in TeX Live.



          with flux arrows



          documentclass[tikz]{standalone}
          usepackage{tikz-3dplot}

          begin{document}
          tdplotsetmaincoords{60}{135}

          pgfmathsetmacro{rvec}{.8}

          begin{tikzpicture}[scale=5,tdplot_main_coords]
          coordinate (O) at (0,0,0);

          draw[thick,->] (-1.5,0,0)-- (1.5,0,0) node[anchor=north east]{$x$};
          draw[thick,->] (0,-1.5,0)--(0,1.5,0) node[anchor=north west]{$y$};
          draw[thick,->] (0,0,-1.5)-- (0,0,1.5) node[anchor=south]{$z$};

          shade[tdplot_screen_coords,ball color = white] (0,0) circle (rvec);

          foreach i in {0,20,...,360}
          draw[tdplot_screen_coords,<-] (i:.9*rvec) -- (i: 1.1*rvec);

          node[tdplot_screen_coords] (0,0) {$-1$};
          end{tikzpicture}
          end{document}






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 22 at 11:48

























          answered Feb 22 at 11:17









          TeXnicianTeXnician

          25.9k63390




          25.9k63390













          • Thanks a lot! Is there a way to get those flux arrows(pointing inside the sphere) also? Is there a way to get an equator? Also the axes to be seen but bit blur inside the sphere?

            – Shamina
            Feb 22 at 11:40













          • @Shamina I have added some arrows. Could you please edit your question to make the other requirements more clear (which type of blurring do you refer to and where do you want the equator to be)?

            – TeXnician
            Feb 22 at 11:48











          • I edited my answer. I mean blurring inside the sphere

            – Shamina
            Feb 22 at 13:02



















          • Thanks a lot! Is there a way to get those flux arrows(pointing inside the sphere) also? Is there a way to get an equator? Also the axes to be seen but bit blur inside the sphere?

            – Shamina
            Feb 22 at 11:40













          • @Shamina I have added some arrows. Could you please edit your question to make the other requirements more clear (which type of blurring do you refer to and where do you want the equator to be)?

            – TeXnician
            Feb 22 at 11:48











          • I edited my answer. I mean blurring inside the sphere

            – Shamina
            Feb 22 at 13:02

















          Thanks a lot! Is there a way to get those flux arrows(pointing inside the sphere) also? Is there a way to get an equator? Also the axes to be seen but bit blur inside the sphere?

          – Shamina
          Feb 22 at 11:40







          Thanks a lot! Is there a way to get those flux arrows(pointing inside the sphere) also? Is there a way to get an equator? Also the axes to be seen but bit blur inside the sphere?

          – Shamina
          Feb 22 at 11:40















          @Shamina I have added some arrows. Could you please edit your question to make the other requirements more clear (which type of blurring do you refer to and where do you want the equator to be)?

          – TeXnician
          Feb 22 at 11:48





          @Shamina I have added some arrows. Could you please edit your question to make the other requirements more clear (which type of blurring do you refer to and where do you want the equator to be)?

          – TeXnician
          Feb 22 at 11:48













          I edited my answer. I mean blurring inside the sphere

          – Shamina
          Feb 22 at 13:02





          I edited my answer. I mean blurring inside the sphere

          – Shamina
          Feb 22 at 13:02


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476138%2ftrying-to-make-a-3dplot%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How do I know what Microsoft account the skydrive app is syncing to?

          When does type information flow backwards in C++?

          Grease: Live!