Python Forum
User input numpy array with color mapping & mouse click events
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
User input numpy array with color mapping & mouse click events
#1
Hello Members!

I am new to the forum and looking for some help with a project related coding question.

I am tasked with making a 2d numpy array which would be based on the user inputing the number of rows and columns. Once the array is made, random values are to be inserted into them which would then be normalized between 0 & 1. To this I am supposed to add color mapping as well as a mouse click event counter which would select one column when the mouse button is pressed and highlight it as "HIGH" and display it in red while other cells remain in other colours except red.

Looking at some online resources this looks like a slider window problem to me but being a newbie I am not exactly sure how to do that here.

My code so far is as follows:


## Sliding window iterator over a 2d mxn array with a color grid
## Added mouse click events


### import all necessary modules
import time
import numpy as np
from itertools import islice
from pylab import arange, cm, draw, rand
from matplotlib import pylab as plt
from time import sleep
from numpy import random
import random

## program start
plt.ion()


# user input variables
numOfSignals = int(input("Enter Number of Signals (Rows): "))
numOfSamples = int(input("Enter Number of Samples (Columns): "))
#RunTime = int(input("Enter Desired Time: "))

start_time = time.time()

## initialize the 2d array

def user_matrix():
    matrix = []; columns = []
    for i in range(0,numOfSignals):
        matrix.append([])
        for j in range(0,numOfSamples):
            matrix[i].append(0)

    data = rand(numOfSignals*200)
    data = data.reshape(numOfSignals,200)
    return data

    ## random value input for matrix
        ## display matrix with random value

    ## Randomise betn 0 & 1

    ## add color mapping to this matrix
        ## return color mapped matrix

    ## add time variable and get the matrix to run for user input time
        ## return the color mapped moving matrix

#def user_event():

    ## mouseclick event
        ## show event register

    ## integrate mouseclick with rolling array from above

    ## show mouseclick as a high event or red

    




print("--- %s seconds ---" %(time.time() - start_time))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Simulate an answer based on user input [Beginner needs guidance] Bombardini 1 1,281 Nov-12-2022, 03:47 AM
Last Post: deanhystad
  Print user input into triangle djtjhokie 1 2,369 Nov-07-2020, 07:01 PM
Last Post: buran
  Changing Directory based on user input paulmerton4pope 13 7,988 Aug-14-2020, 11:48 AM
Last Post: GOTO10
  how to add the user input from file into list wilson20 8 4,313 May-03-2020, 10:52 PM
Last Post: Larz60+
  Writing a function that changes its answer based on user input SirRavenclaw 2 2,801 Dec-21-2019, 09:46 PM
Last Post: Clunk_Head
  creating functions which modify numpy array GSGSGKGK 0 1,582 Dec-15-2019, 07:04 PM
Last Post: GSGSGKGK
  Print the longest str from user input edwdas 5 4,138 Nov-04-2019, 02:02 PM
Last Post: perfringo
  how to add user input to a dictionary to a graph KINGLEBRON 3 3,025 Jul-31-2019, 09:09 PM
Last Post: SheeppOSU
  New to Python - tiny coding assistance on user input function and assign to variable Mountain_Duck 1 2,497 Mar-23-2019, 06:54 PM
Last Post: Yoriz
  Extracting list element with user input valve 1 2,565 Mar-11-2019, 07:37 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020