How to give aplot title while plotting a Bloch sphere using QuTiP












1















I am plotting a Bloch sphere figure using QuTiP. I want to give it a title. How can I do this? I searched on Google but could not find an answer.










share|improve this question























  • What have you tried so far?

    – meW
    Jan 2 at 7:10











  • "plt.title('Bloch Sphere')" but it didn't work

    – Parveen
    Jan 2 at 7:12






  • 1





    QuTiP allows for two different versions, Bloch or Bloch3d. You would benefit from showing a minimal example code where you are unable to give your sphere a title, to avoid ambiguities and allow someone to give a definitive answer.

    – ImportanceOfBeingErnest
    Jan 2 at 10:41
















1















I am plotting a Bloch sphere figure using QuTiP. I want to give it a title. How can I do this? I searched on Google but could not find an answer.










share|improve this question























  • What have you tried so far?

    – meW
    Jan 2 at 7:10











  • "plt.title('Bloch Sphere')" but it didn't work

    – Parveen
    Jan 2 at 7:12






  • 1





    QuTiP allows for two different versions, Bloch or Bloch3d. You would benefit from showing a minimal example code where you are unable to give your sphere a title, to avoid ambiguities and allow someone to give a definitive answer.

    – ImportanceOfBeingErnest
    Jan 2 at 10:41














1












1








1








I am plotting a Bloch sphere figure using QuTiP. I want to give it a title. How can I do this? I searched on Google but could not find an answer.










share|improve this question














I am plotting a Bloch sphere figure using QuTiP. I want to give it a title. How can I do this? I searched on Google but could not find an answer.







python matplotlib qutip






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 2 at 7:09









ParveenParveen

142




142













  • What have you tried so far?

    – meW
    Jan 2 at 7:10











  • "plt.title('Bloch Sphere')" but it didn't work

    – Parveen
    Jan 2 at 7:12






  • 1





    QuTiP allows for two different versions, Bloch or Bloch3d. You would benefit from showing a minimal example code where you are unable to give your sphere a title, to avoid ambiguities and allow someone to give a definitive answer.

    – ImportanceOfBeingErnest
    Jan 2 at 10:41



















  • What have you tried so far?

    – meW
    Jan 2 at 7:10











  • "plt.title('Bloch Sphere')" but it didn't work

    – Parveen
    Jan 2 at 7:12






  • 1





    QuTiP allows for two different versions, Bloch or Bloch3d. You would benefit from showing a minimal example code where you are unable to give your sphere a title, to avoid ambiguities and allow someone to give a definitive answer.

    – ImportanceOfBeingErnest
    Jan 2 at 10:41

















What have you tried so far?

– meW
Jan 2 at 7:10





What have you tried so far?

– meW
Jan 2 at 7:10













"plt.title('Bloch Sphere')" but it didn't work

– Parveen
Jan 2 at 7:12





"plt.title('Bloch Sphere')" but it didn't work

– Parveen
Jan 2 at 7:12




1




1





QuTiP allows for two different versions, Bloch or Bloch3d. You would benefit from showing a minimal example code where you are unable to give your sphere a title, to avoid ambiguities and allow someone to give a definitive answer.

– ImportanceOfBeingErnest
Jan 2 at 10:41





QuTiP allows for two different versions, Bloch or Bloch3d. You would benefit from showing a minimal example code where you are unable to give your sphere a title, to avoid ambiguities and allow someone to give a definitive answer.

– ImportanceOfBeingErnest
Jan 2 at 10:41












1 Answer
1






active

oldest

votes


















0














You will need to render the Bloch sphere to an axes in a 3D figure in matploltib.
Below is an example of how to do this:



import matplotlib.pyplot as plt
import quitp

# needs Axes3D object to activate the '3d' projection
from mpl_toolkits.mplot3d import Axes3D

fig, ax = plt.subplots(figsize=(5, 5), subplot_kw=dict(projection='3d'))

ax.axis('square') # to get a nice circular plot

b1 = qutip.Bloch(fig=fig, axes=ax)
b1.add_states(qutip.sigmax()/2)
b1.zlabel = ['z', '']
b1.render(fig=fig, axes=ax) # render to the correct subplot

# set title for the axis
ax.set_title('TITLE goes here', y=1.1, fontsize=20)

# You can anything else you want to the axis as well!
ax.annotate('TEXT', xy=(0.1, 0.9), xytext=(0.1, 0.7), xycoords='axes fraction',
fontsize=15, color='r', ha='center',)

plt.show()


Here is the output:



enter image description here



Ideally, once we set the fig and ax in the call to Bloch, it should have automatically plotted to the correct axes, but the render function is set by default to fig=None, axis=None. This is a possibly a small bug.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2fstackoverflow.com%2fquestions%2f54002534%2fhow-to-give-aplot-title-while-plotting-a-bloch-sphere-using-qutip%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You will need to render the Bloch sphere to an axes in a 3D figure in matploltib.
    Below is an example of how to do this:



    import matplotlib.pyplot as plt
    import quitp

    # needs Axes3D object to activate the '3d' projection
    from mpl_toolkits.mplot3d import Axes3D

    fig, ax = plt.subplots(figsize=(5, 5), subplot_kw=dict(projection='3d'))

    ax.axis('square') # to get a nice circular plot

    b1 = qutip.Bloch(fig=fig, axes=ax)
    b1.add_states(qutip.sigmax()/2)
    b1.zlabel = ['z', '']
    b1.render(fig=fig, axes=ax) # render to the correct subplot

    # set title for the axis
    ax.set_title('TITLE goes here', y=1.1, fontsize=20)

    # You can anything else you want to the axis as well!
    ax.annotate('TEXT', xy=(0.1, 0.9), xytext=(0.1, 0.7), xycoords='axes fraction',
    fontsize=15, color='r', ha='center',)

    plt.show()


    Here is the output:



    enter image description here



    Ideally, once we set the fig and ax in the call to Bloch, it should have automatically plotted to the correct axes, but the render function is set by default to fig=None, axis=None. This is a possibly a small bug.






    share|improve this answer




























      0














      You will need to render the Bloch sphere to an axes in a 3D figure in matploltib.
      Below is an example of how to do this:



      import matplotlib.pyplot as plt
      import quitp

      # needs Axes3D object to activate the '3d' projection
      from mpl_toolkits.mplot3d import Axes3D

      fig, ax = plt.subplots(figsize=(5, 5), subplot_kw=dict(projection='3d'))

      ax.axis('square') # to get a nice circular plot

      b1 = qutip.Bloch(fig=fig, axes=ax)
      b1.add_states(qutip.sigmax()/2)
      b1.zlabel = ['z', '']
      b1.render(fig=fig, axes=ax) # render to the correct subplot

      # set title for the axis
      ax.set_title('TITLE goes here', y=1.1, fontsize=20)

      # You can anything else you want to the axis as well!
      ax.annotate('TEXT', xy=(0.1, 0.9), xytext=(0.1, 0.7), xycoords='axes fraction',
      fontsize=15, color='r', ha='center',)

      plt.show()


      Here is the output:



      enter image description here



      Ideally, once we set the fig and ax in the call to Bloch, it should have automatically plotted to the correct axes, but the render function is set by default to fig=None, axis=None. This is a possibly a small bug.






      share|improve this answer


























        0












        0








        0







        You will need to render the Bloch sphere to an axes in a 3D figure in matploltib.
        Below is an example of how to do this:



        import matplotlib.pyplot as plt
        import quitp

        # needs Axes3D object to activate the '3d' projection
        from mpl_toolkits.mplot3d import Axes3D

        fig, ax = plt.subplots(figsize=(5, 5), subplot_kw=dict(projection='3d'))

        ax.axis('square') # to get a nice circular plot

        b1 = qutip.Bloch(fig=fig, axes=ax)
        b1.add_states(qutip.sigmax()/2)
        b1.zlabel = ['z', '']
        b1.render(fig=fig, axes=ax) # render to the correct subplot

        # set title for the axis
        ax.set_title('TITLE goes here', y=1.1, fontsize=20)

        # You can anything else you want to the axis as well!
        ax.annotate('TEXT', xy=(0.1, 0.9), xytext=(0.1, 0.7), xycoords='axes fraction',
        fontsize=15, color='r', ha='center',)

        plt.show()


        Here is the output:



        enter image description here



        Ideally, once we set the fig and ax in the call to Bloch, it should have automatically plotted to the correct axes, but the render function is set by default to fig=None, axis=None. This is a possibly a small bug.






        share|improve this answer













        You will need to render the Bloch sphere to an axes in a 3D figure in matploltib.
        Below is an example of how to do this:



        import matplotlib.pyplot as plt
        import quitp

        # needs Axes3D object to activate the '3d' projection
        from mpl_toolkits.mplot3d import Axes3D

        fig, ax = plt.subplots(figsize=(5, 5), subplot_kw=dict(projection='3d'))

        ax.axis('square') # to get a nice circular plot

        b1 = qutip.Bloch(fig=fig, axes=ax)
        b1.add_states(qutip.sigmax()/2)
        b1.zlabel = ['z', '']
        b1.render(fig=fig, axes=ax) # render to the correct subplot

        # set title for the axis
        ax.set_title('TITLE goes here', y=1.1, fontsize=20)

        # You can anything else you want to the axis as well!
        ax.annotate('TEXT', xy=(0.1, 0.9), xytext=(0.1, 0.7), xycoords='axes fraction',
        fontsize=15, color='r', ha='center',)

        plt.show()


        Here is the output:



        enter image description here



        Ideally, once we set the fig and ax in the call to Bloch, it should have automatically plotted to the correct axes, but the render function is set by default to fig=None, axis=None. This is a possibly a small bug.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 19 at 11:21









        krmkrm

        1038




        1038
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • 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%2fstackoverflow.com%2fquestions%2f54002534%2fhow-to-give-aplot-title-while-plotting-a-bloch-sphere-using-qutip%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

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            Npm cannot find a required file even through it is in the searched directory