Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9128857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:36:50+00:00 2026-06-17T07:36:50+00:00

I am seeing some strange results from matplotlib, I am using pretty much the

  • 0

I am seeing some strange results from matplotlib, I am using pretty much the stock example for adding it to Django;

def graph(request):
if request.user.is_authenticated():
    user = request.user.first_name
else:
    return redirect('/login')


form = GetGraphData(request.POST or None)
if form.is_valid():

    os.environ['MPLCONFIGDIR'] = "/tmp"
    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
    from matplotlib.figure import Figure
    from matplotlib.dates import DateFormatter



    from_date = form.cleaned_data['chosen_from_date']
    to_date = form.cleaned_data['chosen_to_date']
    graph_property = form.cleaned_data['chosen_property']
    rack = form.cleaned_data['chosen_rack']
    query = "select %s,reading_date from readings where reading_date" \
            " between '%s' and '%s' and pdu_location like '%s%%'" \
            %(graph_property,from_date, to_date, rack)



    results = db.db_query(query)

    if results[0]: 
        fig=Figure()
        fig.clear()
        ax=fig.add_subplot(111)
        x=[]
        for i in results[0]:
            x.append(i[1])
        y=[]
        for i in results[0]:
            y.append(i[0])

        ax.plot_date(x, y, '-')
        ax.xaxis.set_major_formatter(DateFormatter('%Y-%m-%d'))
        ax.set_title(rack)
        ax.set_xlabel("Date")
        ax.set_ylabel(graph_property)
        fig.autofmt_xdate()
        canvas=FigureCanvas(fig)
        response=HttpResponse(content_type='image/png')
        canvas.print_png(response)
        return response
    else:
        error_message = 'There were no results for that query, check' \
                        ' your dates and try again.' 
        return render_to_response('generic_message.html'
                           ,{'message':error_message,'title':'No results'})




template_dict = {'username':user, 'form':form,'view':True}
return render_to_response('get_circuit.html',template_dict)

The indenting is correct, it just pastes strangely above,
On the x axis we end up with a list of datetime objects, on the y axis we end up with a list of floats.

I get the graph below;
enter image description here

You can see that the left side of the graph is very odd looking.
There are 96 data points that come back as part of this query, I have also noticed that when there are over 1000 data points on the y axis that it goes even crazier.

Would anybody have any suggestions to combat this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:36:51+00:00Added an answer on June 17, 2026 at 7:36 am

    It looks like your points aren’t plotting linearly. I believe ordering by date should fix it

    order by reading_date ASC

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using MVC3 .NET4.0 (VB), and I'm seeing some strange behavior on a simple
I'm implementing drag & drop from a ListBox, but I'm seeing some strange behaviour
I am experimenting with variable argument lists and seeing some strange results... The piece
I've been seeing some strange issues using the Alarm manager in Android, despite the
I'm seeing some strange results when querying INFORMATION_SCHEMA.STATISTICS for index names. When I do
I'm using the HttpClient from the WCF REST Preview release, and we're seeing some
I'm seeing some strange (to me anyway) behavior when using MakeRelativeUri on Mono (2.6.7).
I'm seeing some strange behaviour with my Rails3 app. Note that I'm using the
Seeing some strange things; help is being solicited. I have a query, like so:
I have a third party component I'm using and I'm seeing some issues with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.