Coder Social home page Coder Social logo

Comments (3)

tirthajyoti avatar tirthajyoti commented on May 24, 2024

I am using 3.1.1.

from covid-19-analysis.

bhlevca avatar bhlevca commented on May 24, 2024

I am using 3.1.1.

I have 3.2.1 and your code does not work. I am surprised that it allowed you to put Timestamp in the X axis. pyplot.bar does not allow this.

Also, the named parameters did not work, I had to remove them and l use positional parameters because the new implementation of pyplot.bar is like the following:

def bar(left, height, width=0.8, bottom=None, hold=None, data=None, **kwargs):

You can notice that there is no x, it was replaced by left

This code works for me:
plt.bar(dates.values, cases, color='blue', edgecolor='k')

I got inspired by your code and I created a code for Canada. Although it is substantially changed I will credit you for the initial code in the header. Thanks.

I hope to post it soon on github.com and I hope to add some analysis and predictions based on different scenarios

from covid-19-analysis.

bhlevca avatar bhlevca commented on May 24, 2024

I suggest trying something like the code bleow that beside making it version agnostic will also simply code repetitions in your ranking method

def plot_bar(pos, cases, dt, color, title):
            labels = [val[1] for val in cases]
            x = np.arange(len(labels))  # the label locations
            axs[pos].bar(x, [val[0] for val in cases],
                       color=color, edgecolor='k')
            axs[pos].set_title("{} on {}".format(title, str(dt)),
                             fontsize=15)

            axs[pos].set_xticklabels(labels)

then call in the code like this

    ```

_, axs = plt.subplots(2, 2, figsize=(15, 9))
axs = axs.ravel()
plot_bar(0, sorted_cases, d, 'blue', "Total cases")
plot_bar(1, sorted_deaths, d, 'red', "Total deaths")
plot_bar(2, sorted_newcases, d, 'yellow', "New cases")
plot_bar(3, sorted_newdeaths, d, 'orange', "New deaths")

from covid-19-analysis.

Related Issues (3)

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.