Giter Site home page Giter Site logo

Comments (6)

theengineear avatar theengineear commented on May 5, 2024

Thanks for the feedback! Yes, it should be possible. We actually recently added this feature!

You might have an outdated version. Try simply upgrading and running your script again?

pip install --upgrade plotly

If that doesn't fix it, drop another note here with a replicable code snippet and we can go from there.

from plotly.py.

theengineear avatar theengineear commented on May 5, 2024

I should also note that there is a still a bug that prevents checking if there is no axis line but there are ticks. The default behavior on this figure conversion is to hide the ticks. Just as a heads up.

from plotly.py.

vpekkala avatar vpekkala commented on May 5, 2024

I upgraded latest plotly version 1.1.2 but it does not work. You can see my problem by running code:

-- coding: utf-8 --

import plotly.plotly as py
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec

py.sign_in('USERNAME', 'KEY ID')

mpl_fig_splt2 = plt.figure() # set new mpl figure object

On a 3x3 subplot grid

gs = gridspec.GridSpec(3, 3)
gs.update(wspace=0.5, hspace=0.5) # vertical and horizontal spacing

Subplot 1, top-left

ax1 = mpl_fig_splt2.add_subplot(gs[0,0])
ax1.plot([1,2,3,4,5], [10,5,10,5,10], 'r-', label='sbplt 1')

Subplot 2, top-middle

ax2 = mpl_fig_splt2.add_subplot(gs[0,1])
ax2.plot([1,2,3,4,5], [10,5,10,5,10], 'r-', label='sbplt 2')

Subplot 3, top-right

ax3 = mpl_fig_splt2.add_subplot(gs[0,2])
ax3.plot([1,2,3,4,5], [10,5,10,5,10], 'r-', label='sbplt 3')

Subplot 4, line 2-left

ax4 = mpl_fig_splt2.add_subplot(gs[1,0])
ax4.plot([1,2,3,4,5], [10,5,10,5,10], 'r-', label='sbplt 4')

Subplot 5, line 2-middle

ax5 = mpl_fig_splt2.add_subplot(gs[1,1])
ax5.plot([1,2,3,4,5], [10,5,10,5,10], 'r-', label='sbplt 5')

Subplot 6, line 2-right

ax6 = mpl_fig_splt2.add_subplot(gs[1,2])
ax6.plot([1,2,3,4,5], [10,5,10,5,10], 'r-', label='sbplt 6')

Subplot 7, top over all columns

ax7 = mpl_fig_splt2.add_subplot(gs[2,:])
ax7.plot([1,2,3,4,5], [10,5,10,5,10], 'r-', label='sbplt 7')

NEXT DOES NOT WORK IN PLOTLY:

ax7.tick_params(size=0.01, width=0.01,colors="red")

ax7.spines["bottom"].set_color("none")
ax7.spines["top"].set_color("none")
ax7.spines["left"].set_color("none")
ax7.spines["right"].set_color("none")

NEXT WORKS IN MATPLOTLIB BUT DOES NOT WORK IN PLOTLY:

ax7.set_axis_off()

mpl_fig_splt2.suptitle("Routanousukokeen tulokset", fontsize=10, fontweight='bold')

ax1.set_title("Routanousu", fontsize=10)
ax1.set_xlabel("Aika t (h)", fontsize=8)
ax1.set_ylabel("Routanousu h (mm)", fontsize=8)
ax2.set_title("Routanoususuhde", fontsize=10)
ax2.set_xlabel("Aika t (h)", fontsize=8)
ax2.set_ylabel("Routanoususuhde z", fontsize=8)
ax3.set_title("Segregaatiopotentiaali", fontsize=10)
ax3.set_xlabel("Aika t (h)", fontsize=8)
ax3.set_ylabel("SP (mm^2/Kh)", fontsize=8)
ax4.set_title("Roudan syvyys", fontsize=10)
ax4.set_xlabel("Aika t (h)", fontsize=8)
ax4.set_ylabel("Roudan syvyys H (mm)", fontsize=8)
ax5.set_title("Ohjaus (Syotto ja jaahdytys) lampotilat", fontsize=10)
ax5.set_xlabel("Aika t (h)", fontsize=8)
ax5.set_ylabel("Lampotilat T (C)", fontsize=8)
ax6.set_title("Naytteen (15,35,55,75,95 mm) lampotilat", fontsize=10)
ax6.set_xlabel("Aika t (h)", fontsize=8)
ax6.set_ylabel("Lampotila T (C)", fontsize=8)

ax7.set_axis_off() WORKS IN MATPLOLIB

plt.show()

ax7.set_axis_off() DOES NOT WORK IN PLOTLY

py.plot_mpl(mpl_fig_splt2, filename='s6_subplots2', fileopt='overwrite')

from plotly.py.

theengineear avatar theengineear commented on May 5, 2024

@vpekkala:
Okay, I just ran a notebook that shows the (1) the mpl figure, (2) the first conversion that's a little buggy, and (3) an updated version. Have a look and let me know if things still aren't looking right!

http://nbviewer.ipython.org/gist/theengineear/c059c673d362705063ab

from plotly.py.

etpinard avatar etpinard commented on May 5, 2024

I am confirming the bug: the bottom plotly subplot erroneously contains ticks and ticks labels.

One can get around this bug --- without resorting to the web GUI --- by adding the following lines of code to the above:

update = dict(layout=dict(
    xaxis7 = dict(
        ticks='',
        showticklabels=False
    ),
    yaxis7 = dict(
        ticks='',
        showticklabels=False
    )
))

py.plot_mpl(mpl_fig_splt2, update=update, filename='s6_subplots2')

which updates the plotly figure object with the specifications in update before plotting.

from plotly.py.

vpekkala avatar vpekkala commented on May 5, 2024

Thanks a lot! Now it works fine. This bug can be closed. Still I recommend you to make this change work so that adding "ax7.set_axis_off()" is enough, i.e. without need to add update part into matplotlib code (easier life atleast to unexperienced coders like me...)

from plotly.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.