Question

Working with Python! I am trying to use matplotlib on the jupyter notebook to graph a...

Working with Python! I am trying to use matplotlib on the jupyter notebook to graph a smooth curve scatter plot from data points in a dictionary like this, for example, and the positions of x and y are (x,y)

sampleData = {"sample 1": ('3','5'), "sample 2": ('2','1'), "sample 3": ('2','2'), "sample 4":('6','7')}

Homework Answers

Answer #1

CODE:

import matplotlib.pyplot as plt

sampleData = {"sample 1": ('3', '5'), "sample 2": ('2', '1'), "sample 3": ('2', '2'), "sample 4": ('6', '7')}
x = []
y = []
# cleaning the dictionary to create 2 list of x and y co-ordinate
for i in sampleData.items():
    x.append(int(i[1][0]))
    y.append(int(i[1][1]))
# plotting the list
plt.scatter(x, y, c="blue")

plt.show()

OUTPUT:

Please upvote if you like my answer and comment below if you have any queries or need any further explanation.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
write a program in python for following x = { 'a' : 1 , 'b':2 ,...
write a program in python for following x = { 'a' : 1 , 'b':2 , 'c':3, 'd':4 } For the following key,value pairs of dictionary display those which are even values i.e for which the value is even. i am trying like this but getting confused. (k:v for k,v in x.items() if v%2 != 0
In python: I am trying to construct a list using enumerate and takewhile from a Fibonaci...
In python: I am trying to construct a list using enumerate and takewhile from a Fibonaci generator. So far the code I have is the following: def fibonacci(): (a, b) = (0, 1) while True: yield a (a, b) = (b, a + b) def createlist(n, fib): return [elem for (i, elem) in enumerate(takewhile(lambda x: x < n, fib)) if i < n] I only get half the list when I do: print(createlist(n, fibonacci())) Output: [0, 1, 1, 2, 3,...
Hello, I am trying to use python to calculate the terminal velocity of an object falling...
Hello, I am trying to use python to calculate the terminal velocity of an object falling from a height of 3 meters. I have gotten stuck trying to actually calculate the terminal velocity. thanks for the help! Here I have posted the code I have so far. from visual import* myscene = display(range = 10, width = 600, heigth = 600, background = color.blue, title = 'lab 5' ) #display window s = vector(0,3,0) #vector for starting position m =...
I am working on exercise 5.30 from Introduction to Computing using python (Author: Perkovic). I was...
I am working on exercise 5.30 from Introduction to Computing using python (Author: Perkovic). I was looking at the solution and was able to understand what to do. However, when I implement the temp function as indicated, I keep getting this error "ValueError: the first two maketrans arguments must have equal length". However, it seems my two arguments are equal length, so I'm not sure what I am doing wrong! print('Exercise 5.30') def many(file): infile = open(file) content = infile.read()...
I am trying to figure out how to find the most common word length in the...
I am trying to figure out how to find the most common word length in the british dictionary. I have inputted the text file for the british dictionary into my program. I tried a tedious way, but it doesn't seem effective. Can someone help me? String longestWord = "";        int maxLength =0;        int count1 =0, count2 =0, count3=0, count4=0, count5=0, count6=0, count7=0, count8=0, count9=0, count10=0;        Scanner scanFile = new Scanner (new File("BritishDictionary.txt"));       ...
I've been trying to figure it out for hours but I am still confused. What is...
I've been trying to figure it out for hours but I am still confused. What is the value of MAD? Week Time Series Value Forecast 1 6 7.00 2 5 3.00 3 4 3.00 4 7 4.00 What is the value of MSE? Month Actuals Forecast 1 7 4.00 2 5 3.00 3 4 4.00 4 3 6.00
This is an example out of my text which I copied directly but am getting an...
This is an example out of my text which I copied directly but am getting an error every iteration and am unsure how to correct it. The error is " the condition has length > 1 and only the first element will be used" and my code is: f <- function(x, sigma) { if (any(x < 0)) return(0) stopifnot(sigma > 0) return((x/sigma^2)*exp(-x^2 / (s*sigma^2))) } xt <- x[i-1] y <- rchisq(1, df = xt) m <- 10000 sigma <- 4...
So, i have this code in python that i'm running. The input file is named input2.txt...
So, i have this code in python that i'm running. The input file is named input2.txt and looks like 1.8 4.5 1.1 2.1 9.8 7.6 11.32 3.2 0.5 6.5 The output2.txt is what i'm trying to achieve but when the code runs is comes up blank The output doc is created and the code doesn't error out. it should look like this Sample Program Output 70 - 510, [semester] [year] NAME: [put your name here] PROGRAMMING ASSIGN MENT #2 Enter...
This is the code I am working on for a project using MATLAB: clc,clear G=27.7*10.^9; b=0.286*10.^-9;...
This is the code I am working on for a project using MATLAB: clc,clear G=27.7*10.^9; b=0.286*10.^-9; v=0.334; x=(-5*10.^-9:0.1:5*10.^-9); y=(-5*10.^-9:0.1:-1*10.^-9); [xx,yy]=meshgrid(x,y); stress=(-G*b)*yy*(3^xx+yy^2)/(2*pi.*(1-v))*(xx^2+yy^2).^2; figure mesh(xx,yy,stress); grid on xlabel('X') ylabel('Y') zlabel('Stress') Whenever I try to run this I keep getting the "Error using mesh" line, and then an error for "mesh(xx,yy,stress)". I know I am not catching the issue but how do I fix this? If you could explain as well that be extremely helpful!
So for one of my classes I am updating the game Minesweeper. So for the game...
So for one of my classes I am updating the game Minesweeper. So for the game I was wanting to change the size of the grid based on user preference. I am new to working with tkMesseageBoxs. I am trying to update the variable SIZE_X and SIZE_Y with the tkMeassage box. Size_x and Size_y control the size of the grid. For the first one I tried assigning it to the variable a and b. For the other variables I was...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT