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
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 =...
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...
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...
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!
The data below is from the 2015 influenza record from the U.S. Centers for Disease Control....
The data below is from the 2015 influenza record from the U.S. Centers for Disease Control. What type of graph(s) would be most appropriate to show the week with the maximum number of influenza specimens? Week Influenza Specimens Week Influenza Specimens 1 4908 10 458 2 4586 11 340 3 3917 12 227 4 3475 13 168 5 2719 14 87 6 1745 15 66 7 1242 16 48 8 954 17 26 9 774 18 12 Check all that...
How would I use given data to generate lags? For example, I am given the variable...
How would I use given data to generate lags? For example, I am given the variable DMortgage. How would I generate lags of DMortgage(t): DMortgage (t-1), DMortgage (t-2), DMortgage (t-3), and DMortgage (t-4)?
​(a) Draw a scatter diagram of the data. Choose the correct graph below. A. 010020xy A...
​(a) Draw a scatter diagram of the data. Choose the correct graph below. A. 010020xy A scatter diagram has a horizontal x-axis labeled from 0 to 10 in increments of 1 and a vertical y-axis labeled from 0 to 20 in increments of 2. The following 5 points are plotted, listed here from left to right: (2, 4); (4, 8); (7, 12); (7, 14); (8, 18). B. 010020xy A scatter diagram has a horizontal x-axis labeled from 0 to 10...