Search Results

Search found 832 results on 34 pages for 'plot'.

Page 6/34 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Length-1 arrays can be converted to python scalars error? python

    - by Randy
    from numpy import * from pylab import * from math import * def LogisticMap(a,x): return 4.*a*x*(1.-x) def CosineMap(a,x): return a*cos(x/(2.*pi)) def TentMap(a,x): if x>= 0 or x<0.5: return 2.*a*x if x>=0.5 or x<=1.: return 2.*a*(1.-x) a = 0.98 N = 40 xaxis = arange(0.0,N,1.0) Func = CosineMap subplot(211) title(str(Func.func_name) + ' at a=%g and its second iterate' %a) ylabel('X(n+1)') # set y-axis label plot(xaxis,Func(a,xaxis), 'g', antialiased=True) subplot(212) ylabel('X(n+1)') # set y-axis label xlabel('X(n)') # set x-axis label plot(xaxis,Func(a,Func(a,xaxis)), 'bo', antialiased=True) My program is supposed to take any of the three defined functions and plot it. They all take in a value x from the array xaxis from 0 to N and then return the value. I want it to plot a graph of xaxis vs f(xaxis) with f being any of the three above functions. The logisticmap function works fine, but for CosineMap i get the error "only length-1 arrays can be converted to python scalars" and for TentMap i get error "The truth value of an array with more than one element is ambiguous, use a.any() or a.all()". My tent map function is suppose to return 2*a*x if 0<=x<0.5 and it's suppose to return 2*a*(1-x) if 0.5<=0<=1.

    Read the article

  • Polygon with different line width (in R)

    - by Tal Galili
    Hi all, I would like to use a command like this: plot(c(1,8), 1:2, type="n") polygon(1:7, c(2,1,2,NA,2,1,2), col=c("red", "blue"), # border=c("green", "yellow"), border=c(1,10), lwd=c(1:10)) To create two triangles, with different line widths. But the polygon command doesn't seem to recycle the "lwd" parameter as it does the col or the border parameters. I would like the resulting plot to look like what the following code will produce: plot(c(1,8), 1:2, type="n") polygon(1:3, c(2,1,2), col=c("red"), # border=c("green", "yellow"), border=c(1,10), lwd=c(1)) polygon(5:7, c(2,1,2), col=c( "blue"), # border=c("green", "yellow"), border=c(1,10), lwd=c(10)) So my questions are: Is there something like polygon that does what I asked for? (If not, I would do it by creating a new polygon function that will break the original x,y by their NA's, although I am not yet sure what is the smartest way to do that...) Thanks, Tal

    Read the article

  • Matplotlib plotting non uniform data in 3D surface

    - by Raj Tendulkar
    I have a simple code to plot the points in 3D for Matplotlib as below - from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt import numpy as np from numpy import genfromtxt import csv fig = plt.figure() ax = fig.add_subplot(111, projection='3d') my_data = genfromtxt('points1.csv', delimiter=',') points1X = my_data[:,0] points1Y = my_data[:,1] points1Z = my_data[:,2] ## I remove the header of the CSV File. points1X = np.delete(points1X, 0) points1Y = np.delete(points1Y, 0) points1Z = np.delete(points1Z, 0) # Convert the array to 1D array points1X = np.reshape(points1X,points1X.size) points1Y = np.reshape(points1Y,points1Y.size) points1Z = np.reshape(points1Z,points1Z.size) my_data = genfromtxt('points2.csv', delimiter=',') points2X = my_data[:,0] points2Y = my_data[:,1] points2Z = my_data[:,2] ## I remove the header of the CSV File. points2X = np.delete(points2X, 0) points2Y = np.delete(points2Y, 0) points2Z = np.delete(points2Z, 0) # Convert the array to 1D array points2X = np.reshape(points2X,points2X.size) points2Y = np.reshape(points2Y,points2Y.size) points2Z = np.reshape(points2Z,points2Z.size) ax.plot(points1X, points1Y, points1Z, 'd', markersize=8, markerfacecolor='red', label='points1') ax.plot(points2X, points2Y, points2Z, 'd', markersize=8, markerfacecolor='blue', label='points2') plt.show() My problem is that I tried to make a decent surface plot out of these data points that I have. I already tried to use ax.plot_surface() function to make it look nice. For this I eliminated some points, and recalculated the matrix kind of input needed by this function. However, the graph I generated was far more difficult to interpret and understand. So there might be 2 possibilities: either I am not using the function correctly, or otherwise, the data I am trying to plot is not good for the surface plot. What I was expecting was 3D graph which would have an effect similar to that we have of 3D pie chart. We see that one piece (that which is extracted out) is part of another piece. I was not expecting it to be exactly same like that, but some kind of effect like that. What I would like to ask is: Do you think it will be possible to make such 3D graph? Is there any way better, I could express my data in 3 dimension? Here are the 2 files - points1.csv Dim1,Dim2,Dim3 3,8,1 3,8,2 3,8,3 3,8,4 3,8,5 3,9,1 3,9,2 3,9,3 3,9,4 3,9,5 3,10,1 3,10,2 3,10,3 3,10,4 3,10,5 3,11,1 3,11,2 3,11,3 3,11,4 3,11,5 3,12,1 3,12,2 3,13,1 3,13,2 3,14,1 3,14,2 3,15,1 3,15,2 3,16,1 3,16,2 3,17,1 3,17,2 3,18,1 3,18,2 4,8,1 4,8,2 4,8,3 4,8,4 4,8,5 4,9,1 4,9,2 4,9,3 4,9,4 4,9,5 4,10,1 4,10,2 4,10,3 4,10,4 4,10,5 4,11,1 4,11,2 4,11,3 4,11,4 4,11,5 4,12,1 4,13,1 4,14,1 4,15,1 4,16,1 4,17,1 4,18,1 5,8,1 5,8,2 5,8,3 5,8,4 5,8,5 5,9,1 5,9,2 5,9,3 5,9,4 5,9,5 5,10,1 5,10,2 5,10,3 5,10,4 5,10,5 5,11,1 5,11,2 5,11,3 5,11,4 5,11,5 5,12,1 5,13,1 5,14,1 5,15,1 5,16,1 5,17,1 5,18,1 6,8,1 6,8,2 6,8,3 6,8,4 6,8,5 6,9,1 6,9,2 6,9,3 6,9,4 6,9,5 6,10,1 6,11,1 6,12,1 6,13,1 6,14,1 6,15,1 6,16,1 6,17,1 6,18,1 7,8,1 7,8,2 7,8,3 7,8,4 7,8,5 7,9,1 7,9,2 7,9,3 7,9,4 7,9,5 and points2.csv Dim1,Dim2,Dim3 3,12,3 3,12,4 3,12,5 3,13,3 3,13,4 3,13,5 3,14,3 3,14,4 3,14,5 3,15,3 3,15,4 3,15,5 3,16,3 3,16,4 3,16,5 3,17,3 3,17,4 3,17,5 3,18,3 3,18,4 3,18,5 4,12,2 4,12,3 4,12,4 4,12,5 4,13,2 4,13,3 4,13,4 4,13,5 4,14,2 4,14,3 4,14,4 4,14,5 4,15,2 4,15,3 4,15,4 4,15,5 4,16,2 4,16,3 4,16,4 4,16,5 4,17,2 4,17,3 4,17,4 4,17,5 4,18,2 4,18,3 4,18,4 4,18,5 5,12,2 5,12,3 5,12,4 5,12,5 5,13,2 5,13,3 5,13,4 5,13,5 5,14,2 5,14,3 5,14,4 5,14,5 5,15,2 5,15,3 5,15,4 5,15,5 5,16,2 5,16,3 5,16,4 5,16,5 5,17,2 5,17,3 5,17,4 5,17,5 5,18,2 5,18,3 5,18,4 5,18,5 6,10,2 6,10,3 6,10,4 6,10,5 6,11,2 6,11,3 6,11,4 6,11,5 6,12,2 6,12,3 6,12,4 6,12,5 6,13,2 6,13,3 6,13,4 6,13,5 6,14,2 6,14,3 6,14,4 6,14,5 6,15,2 6,15,3 6,15,4 6,15,5 6,16,2 6,16,3 6,16,4 6,16,5 6,17,2 6,17,3 6,17,4 6,17,5 6,18,2 6,18,3 6,18,4 6,18,5 7,10,1 7,10,2 7,10,3 7,10,4 7,10,5 7,11,1 7,11,2 7,11,3 7,11,4 7,11,5 7,12,1 7,12,2 7,12,3 7,12,4 7,12,5 7,13,1 7,13,2 7,13,3 7,13,4 7,13,5 7,14,1 7,14,2 7,14,3 7,14,4 7,14,5 7,15,1 7,15,2 7,15,3 7,15,4 7,15,5 7,16,1 7,16,2 7,16,3 7,16,4 7,16,5 7,17,1 7,17,2 7,17,3 7,17,4 7,17,5 7,18,1 7,18,2 7,18,3 7,18,4 7,18,5

    Read the article

  • Matlab: plotting frequency distribution with a curve

    - by Kaly
    I have to plot 10 frequency distributions on one graph. In order to keep things tidy, I would like to avoid making a histogram with bins and would prefer having lines that follow the contour of each histogram plot. I tried the following [counts, bins] = hist(data); plot(bins, counts) But this gives me a very inexact and jagged line. I read about ksdensity, which gives me a nice curve, but it changes the scaling of my y-axis and I need to be able to read the frequencies from the y-axis. Can you recommend anything else?

    Read the article

  • Unable to plot graph using matplotlib

    - by Aman Deep Gautam
    I have the following code which searches all the directory in the current directory and then takes data from those files to plot the graph. The data is read correctly as verified by printing but there are no points plotted on graph. import argparse import os import matplotlib.pyplot as plt #find the present working directory pwd=os.path.dirname(os.path.abspath(__file__)) #find all the folders in the present working directory. dirs = [f for f in os.listdir('.') if os.path.isdir(f)] plt.figure() plt.xlim(0, 20000) plt.ylim(0, 1) for directory in dirs: os.chdir(os.path.join(pwd, directory)); chd_dir = os.path.dirname(os.path.abspath(__file__)) files = [ fl for fl in os.listdir('.') if os.path.isfile(fl) ] print files for f in files: f_obj = open(os.path.join(chd_dir, f), 'r') list_x = [] list_y = [] for i in xrange(0,4): f_obj.next() for line in f_obj: temp_list = line.split() print temp_list list_y.append(temp_list[0]) list_x.append(temp_list[1]) print 'final_lsit' print list_x print list_y plt.plot(list_x, list_y, 'r.') f_obj.close() os.chdir(pwd) plt.savefig("test.jpg") The input files look like the following: 5 865 14709 15573 14709 1.32667e-06 664 0.815601 14719 1.55333e-06 674 0.813277 14729 1.82667e-06 684 0.810185 14739 1.4e-06 694 0.808459 Can anybody help me with why this is happening? Being new I would like to know some tutorial where I can get help with kind of plotting as the tutorial I was following made me end up here. Any help appreciated.

    Read the article

  • What happend to walterzorn.com?

    - by Vinz
    I just wanted to use the function plot from waterzorn.com but it seems like the site is down, I only get 404 responses. Does anybody know what's up with the site and if/when it will be back online? So far I could only find the following thread which doesn't have any answers. If you don't know: Walter Zorn had a JavaScript framework that enabled you to draw vectors with DHTML back before there was canvas.

    Read the article

  • Library is missing

    - by andrejs-igumenovs
    Corresponding to Wiki (http://code.google.com/p/core-plot/wiki/UsingCorePlotInApplications): "Core Plot is built as a static library for iPhone, so you'll need to drag the libCorePlot-CocoaTouch.a static library from under the CorePlot-CocoaTouch.xcodeproj group to your target's Link Binary With Libraries folder." I do not see mentioned library there..

    Read the article

  • Open Office plot graph of a single column

    - by drahcir
    I have a an spreadsheet of a questionnaire I conducted. Each column represents a multiple choice question and the values are the answers selected by each participant. Therefore each column has repeated values. Example : **What is your favourite website?** stackoverflow superuser superuser stackoverflow serverfault So I want a chart that compares the amount of times a value is repeated, preferably in percentage. Something like this :

    Read the article

  • Octave / Matlab: How to plot the roots of a polynomial

    - by Tom
    Hi everyone, Im trying to plot the roots of a polynomial, and i just cant get it. First i create my polynomial p5 = [1 0 0 0 0 -1] %x^5 - 1 r5 = roots(p5) stem (p5) Im using the stem function, but I would like to remove the stems, and just get the circle around the roots. Is this possible, is stem the right command? Thanks in advance, PS: This is not homework, but very close, will tag it if requested.

    Read the article

  • plot data at variable points using gnuplot

    - by Sharat Chandra
    Here is my data file seconds data (x-axis ( y axis points) points) 3.880000, 20 3.920000, 10 3.960000, 20 4.000000, 20 4.080000, 20 4.120000, 20 4.570000, 20 4.620000, 10 4.650000, 10 4.690000, 10 4.750000, 20 . . . and so on I want to plot points in column 2 at positions specified by column 1 ie I want 20 , 10 , 20 20, 20 etc to be present at 3.88 , 3.92, 3.96 on xaxis Can anybody tell me how to do this ?

    Read the article

  • Orcad / Matlab: How to plot the roots of a polynomial

    - by Tom
    Hi everyone, Im trying to plot the roots of a polynomial, and i just cant get it. First i create my polynomial p5 = [1 0 0 0 0 -1] %x^5 - 1 r5 = roots(p5) stem (p5) Im using the stem function, but I would like to remove the stems, and just get the circle around the roots. Is this possible, is stem the right command? Thanks in advance, PS: This is not homework, but very close, will tag it if requested.

    Read the article

  • How to create a "Clustergram" plot ? (in R)

    - by Tal Galili
    Hi all, I came across this interesting website, with an idea of a way to visualize a clustering algorithm called "Clustergram": I am not sure how useful this really is, but in order to play with it I would like to reproduce it with R, but am not sure how to go about doing it. How would you create a line for each item so it would stay consistent throughout the different number of clusters? Here is an example code/data to play with for potential answer: hc <- hclust(dist(USArrests), "ave") plot(hc)

    Read the article

  • Trying to keep filled bars in a faceted plot

    - by John Horton
    Not sure what I'm doing wrong here. I have this plot: ggplot(data.PE5, aes(ybands,fill=factor(decide))) + geom_bar(position="dodge") which produces: Then I want to facet by a factor, creating two stacked plots w/ dodged, colored bars ggplot(data.PE5, aes(ybands,fill=factor(decide))) + geom_bar(position="dodge") + facet_grid(~group_label) However, I lose the factor-based coloring, which I want to keep:

    Read the article

  • Removing specific ticks from matplotlib plot

    - by Jsg91
    I'm trying to remove the origin ticks from my plot below to stop them overlapping, alternatively just moving them away from each other would also be great I tried this: xticks = ax.xaxis.get_major_ticks() xticks[0].label1.set_visible(False) yticks = ax.yaxis.get_major_ticks() yticks[0].label1.set_visible(False) However this removed the first and last ticks from the y axis like so: Does anyone have an idea about how to do this? Any help would be greatly appreciated.

    Read the article

  • Decision region plot for neural network in matlab

    - by Taban
    I have a neural network trained with backpropagation algorithm. I also create data set (input and target) random. Now I want to plot a decision region where each region is marked with a red star or with a blue circle according to whether it belongs to class 1 or -1. I searched a lot but just find plotpc function that is for perceptron algorithm. What should I try now? Any link or answer really helps. Thanks

    Read the article

  • core plot error?

    - by senthilmuthu
    hi, i am using core plot framework,when i run following code in viewdidload gives crash.the view is as custom view... graph = [(CPXYGraph *)[CPXYGraph alloc] initWithFrame:CGRectZero]; CPLayerHostingView *hostingView = (CPLayerHostingView *)self.view; hostingView.hostedLayer = graph;**(gives error)** what i have to do? any help please?

    Read the article

  • Setting XTick or XLabels for a plot containing millisecond data

    - by Dave
    I am trying to set the X-Axis labels on a plot. I have a vector of times, these go down to the millisecond level. I have tried setting both XTick and XTickLabel properties but things are not working correctly (labels are not valid). Any suggestions on what one needs to do to get datetick to work when working with times that go down to the second/millisecond level? Are there any alternatives to using datetick? Any suggestions are appreciated.

    Read the article

  • Thoughts about alternatives to barplot-with-error-bars

    - by gd047
    I was thinking of an alternative to the barplot-with-error-bars plot. To get an idea by example, I roughly 'sketched' what I mean using the following code library(plotrix) plot(0:12,type="n",axes=FALSE) gradient.rect(1,0,3,8,col=smoothColors("red",38,"red"),border=NA,gradient="y") gradient.rect(4,0,6,6,col=smoothColors("blue",38,"blue"),border=NA,gradient="y") lines(c(2,2),c(5.5,10.5)) lines(c(2-.5,2+.5),c(10.5,10.5)) lines(c(2-.5,2+.5),c(5.5,5.5)) lines(c(5,5),c(4.5,7.5)) lines(c(5-.5,5+.5),c(7.5,7.5)) lines(c(5-.5,5+.5),c(4.5,4.5)) gradient.rect(7,8,9,10.5,col=smoothColors("red",100,"white"),border=NA,gradient="y") gradient.rect(7,5.5,9,8,col=smoothColors("white",100,"red"),border=NA,gradient="y") lines(c(7,9),c(8,8),lwd=3) gradient.rect(10,6,12,7.5,col=smoothColors("blue",100,"white"),border=NA,gradient="y") gradient.rect(10,4.5,12,6,col=smoothColors("white",100,"blue"),border=NA,gradient="y") lines(c(10,12),c(6,6),lwd=3) The idea was to use bars like the ones in the second pair, instead of those in the first. However, there is something that I would like to change in the colors. Instead of a linear gradient fill, I would like to adjust the color intensity in accordance with the values of the pdf of the mean estimator. Do you think it is possible? A slightly different idea (where gradient fill isn't an issue) was to use one (or 2 back-to-back) bell curve(s) filled with (solid) color, instead of a rectangle. See for example the shape that corresponds to the letter F here. In that case the bell-curve(s) should (ideally) be drawn using something like plot(x, dnorm(x, mean = my.mean, sd = std.error.of.the.mean)) I have no idea though, of a way to draw rotated (and filled with color) bell curves. Of course, all of the above may be freely judged as midnight springtime dreams :-)

    Read the article

  • Drawing and filling different polygons at the same time in MATLAB

    - by Hossein
    Hi,I have the code below. It load a CSV file into memory. This file contains the coordinates for different polygons.Each row of this file has X,Y coordinates and a string which tells that to which polygon this datapoint belongs. for example a polygone named "Poly1" with 100 data points has 100 rows in this file like : Poly1,X1,Y1 Poly1,X2,Y2 ... Poly1,X100,Y100 Poly2,X1,Y1 ..... The index.csv file has the number of datapoint(number of rows) for each polygon in file Polygons.csv. These details are not important. The thing is: I can successfully extract the datapoints for each polygon using the code below. However, When I plot the lines of different polygons are connected to each other and the plot looks crappy. I need the polygons to be separated(they are connected and overlapping the some areas though). I thought by using "fill" I can actually see them better. But "fill" just filles every polygon that it can find and that is not desirable. I only want to fill inside the polygons. Can someone help me? I can also send you my datapoint if necessary, they are less than 200Kb. Thanks [coordinates,routeNames,polygonData] = xlsread('Polygons.csv'); index = dlmread('Index.csv'); firstPointer = 0 lastPointer = index(1) for Counter=2:size(index) firstPointer = firstPointer + index(Counter) + 1 hold on plot(coordinates(firstPointer:lastPointer,2),coordinates(firstPointer:lastPointer,1),'r-') lastPointer = lastPointer + index(Counter) end

    Read the article

  • "Invalid Handle Object" when plotting 2 figures Matlab

    - by pinnacler
    I'm having a difficult time understanding the paradigm of Matlab classes vs compared to c++. I wrote code the other day, and I thought it should work. It did not... until I added <handle after the classdef. So I have two classes, landmarks and robot, both are called from within the simulation class. This is the main loop of obj.simulation.animate() and it works, until I try to plot two things at once. DATA.path is a record of all the places a robot has been on the map, and it's updated every time the position is updated. When I try to plot it, by uncommenting the two marked lines below, I get this error: ??? Error using == set Invalid handle object. Error in == simulationsimulation.animate at 45 set(l.lm,'XData',obj.landmarks.apparentPositions(:,1),'YData',obj.landmarks.apparentPositions(:,2)); %INITIALIZE GLOBALS global DATA XX XX = [obj.robot.x ; obj.robot.y]; DATA.i=1; DATA.path = XX; %Setup Plots fig=figure; xlabel('meters'), ylabel('meters') set(fig, 'name', 'Phil''s AWESOME 80''s Robot Simulator') xymax = obj.landmarks.mapSize*3; xymin = -(obj.landmarks.mapSize*3); l.lm=scatter([0],[0],'b+'); %"UNCOMMENT ME"l.pth= plot(0,0,'k.','markersize',2,'erasemode','background'); % vehicle path axis([xymin xymax xymin xymax]); %Simulation Loop for n = 1:720, %Calculate and Set Heading/Location XX = [obj.robot.x;obj.robot.y]; store_data(XX); if n == 120, DATA.path end %Update Position headingChange = navigate(n); obj.robot.updatePosition(headingChange); obj.landmarks.updatePerspective(obj.robot.heading, obj.robot.x, obj.robot.y); %Animate %"UNCOMMENT ME" set(l.pth, 'xdata', DATA.path(1,1:DATA.i), 'ydata', DATA.path(2,1:DATA.i)); set(l.lm,'XData',obj.landmarks.apparentPositions(:,1),'YData',obj.landmarks.apparentPositions(:,2)); rectangle('Position',[-2,-2,4,4]); drawnow This is the classdef for landmarks classdef landmarks <handle properties fixedPositions; %# positions in a fixed coordinate system. [ x, y ] mapSize; %Map Size. Value is side of square x; y; heading; headingChange; end properties (Dependent) apparentPositions end methods function obj = landmarks(mapSize, numberOfTrees) obj.mapSize = mapSize; obj.fixedPositions = obj.mapSize * rand([numberOfTrees, 2]) .* sign(rand([numberOfTrees, 2]) - 0.5); end function apparent = get.apparentPositions(obj) currentPosition = [obj.x ; obj.y]; apparent = bsxfun(@minus,(obj.fixedPositions)',currentPosition)'; apparent = ([cosd(obj.heading) -sind(obj.heading) ; sind(obj.heading) cosd(obj.heading)] * (apparent)')'; end function updatePerspective(obj,tempHeading,tempX,tempY) obj.heading = tempHeading; obj.x = tempX; obj.y = tempY; end end end To me, this is how I understand things. I created a figure l.lm that has about 100 xy points. I can rotate this figure by using set(l.lm,'XData',obj.landmarks.apparentPositions(:,1),'YData',obj.landmarks.apparentPositions(:,2)); When I do that, things work. When I try to plot a second group of XY points, stored in DATA.path, it craps out and I can't figure out why.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >