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 6048911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:30:59+00:00 2026-05-23T07:30:59+00:00

My question is almost exactly similar to this one . However , I’m not

  • 0

My question is almost exactly similar to this one. However, I’m not satisfied with the answers, because I want to generate an actual heatmap, without explicitely binning the data.

To be precise, I would like to display the function that is the result of a convolution between the scatter data and a custom kernel, such as 1/x^2.

How should I implement this with matplotlib?

EDIT: Basically, what I have done is this. The result is here. I’d like to keep everything, the axis, the title, the labels and so on. Basically just change the plot to be like I described, while re-implementing as little as possible.

  • 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-05-23T07:31:00+00:00Added an answer on May 23, 2026 at 7:31 am

    Convert your time series data into a numeric format with matplotlib.dats.date2num. Lay down a rectangular grid that spans your x and y ranges and do your convolution on that plot. Make a pseudo-color plot of your convolution and then reformat the x labels to be dates.

    The label formatting is a little messy, but reasonably well documented. You just need to replace AutoDateFormatter with DateFormatter and an appropriate formatting string.

    You’ll need to tweak the constants in the convolution for your data.

    import numpy as np
    import datetime as dt
    import pylab as plt
    import matplotlib.dates as dates
    
    t0 = dt.date.today()
    t1 = t0+dt.timedelta(days=10)
    
    times = np.linspace(dates.date2num(t0), dates.date2num(t1), 10)
    dt = times[-1]-times[0]
    price =  100 - (times-times.mean())**2
    dp = price.max() - price.min()
    volume = np.linspace(1, 100, 10)
    
    tgrid = np.linspace(times.min(), times.max(), 100)
    pgrid = np.linspace(70, 110, 100)
    tgrid, pgrid = np.meshgrid(tgrid, pgrid)
    heat = np.zeros_like(tgrid)
    
    for t,p,v in zip(times, price, volume):
        delt = (t-tgrid)**2
        delp = (p-pgrid)**2
        heat += v/( delt + delp*1.e-2 + 5.e-1 )**2
    
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.pcolormesh(tgrid, pgrid, heat, cmap='gist_heat_r')
    
    plt.scatter(times, price, volume, marker='x')
    
    locator = dates.DayLocator()
    ax.xaxis.set_major_locator(locator)
    ax.xaxis.set_major_formatter(dates.AutoDateFormatter(locator))
    fig.autofmt_xdate()
    
    plt.show()
    

    Script output

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

Sidebar

Related Questions

My question is almost exactly the same as this question , however the answer
This one is almost a philosophical question: is it bad to access and/or set
There is a question that does almost exactly what I want to do by
This is almost exactly the same as this question json get key names as
My question is almost exactly the same as this post , except that I'm
My question is almost exactly this question: Clone textview to append it to a
Seeing various locking related question and (almost) always finding the 'loop because of spurious
When I asked this question I got almost always a definite yes you should
I am almost embarrassed to ask this question, but as a long time C
This is almost certainly a very silly question, but for some reason I'm having

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.