Plotting x-y points with Breeze Viz

1,412 views
Skip to first unread message

Adelbert Chang

unread,
Jan 10, 2013, 2:17:40 PM1/10/13
to scala-...@googlegroups.com
Hello,

If I have something like a Vector[(Double, Double)], where an element (X, Y) represents the x and y coordinates of that elements, is there an easy way I can plot this (just the points)?

Also, is there an easy way to make the X and/or Y axis logscale?

Thanks!
Regards,
-Adelbert

David Hall

unread,
Jan 15, 2013, 1:32:09 AM1/15/13
to scala-...@googlegroups.com
There isn't support for any of that right now. Sorry. I guess you can
unzip the vector and pass them in. There's nothing for log scale atm.
Open a ticket for both of these?
> --
> You received this message because you are subscribed to the Google Groups
> "Scala Breeze" group.
> To post to this group, send email to scala-...@googlegroups.com.
> To unsubscribe from this group, send email to
> scala-breeze...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/scala-breeze/-/EXJGGnfmf7sJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Adelbert Chang

unread,
Jan 17, 2013, 11:32:30 AM1/17/13
to scala-...@googlegroups.com
My mistake, I had not realized you could call plot on a collection of X and Y, though in retrospect that would've been something obvious to test. Apologies, as I am still new to these plotting libraries, dabbling with MATLAB, Python's matplotlib, and Breeze, thankfully all of which seem to have very similar APIs.

I will put in a ticket for logscale.

Keep up the good work!

Michael Schmitz

unread,
Mar 27, 2013, 12:28:17 PM3/27/13
to scala-...@googlegroups.com
I didn't get it from this thread, but I think Adelbert meant that it's possible to plot two Seqs of Doubles, the first one representing the Xes and the second representing the Ys.

    val points: Seq[(Double, Double)]
    val f = Figure()
    val p = f.subplot(0)
    p += plot(points.map(_._1), points.map(_._2))

KiranKumar Adam

unread,
May 3, 2013, 5:30:31 PM5/3/13
to scala-...@googlegroups.com
Hello,

I'd like to plot some discrete values of DenseVector[Double] with length 2 . I'd like to call this function for 100 iterations in main
 
import breeze.plot._
import breeze.linalg._

object Plotting {


  val f = Figure()
  val p = f.subplot(0)
  p.xlim(-400,400)
  p.ylim(-400,400)
 
  def plotter(state: DenseVector[Double]) = {
   
  // state(0) is x co-ordinate and state(1) is y co-ordinate
   p += plot(state(0),state(1))
  
  }
 
}
I'm trying something similar to plot function in matlab where  linspace() is not needed for me.

David Hall

unread,
May 3, 2013, 5:38:47 PM5/3/13
to scala-...@googlegroups.com
We don't have anything in particular for supporting that. Breeze
really expects you to plot aligned sequences of data. Also, plot is
for line graphs, and scatter is for point graphs, which might be more
useful here.

Try this:

p += scatter(state(0 to 0), state(1 to 1), {_ => 0.01})

-- David
> --
> You received this message because you are subscribed to the Google Groups
> "Scala Breeze" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scala-breeze...@googlegroups.com.
> To post to this group, send email to scala-...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/scala-breeze/-/6v6sY-qIA2wJ.

KiranKumar Adam

unread,
May 4, 2013, 6:46:46 AM5/4/13
to scala-...@googlegroups.com
Hello ,

This is my example on worksheet  and  I'm not getting any results even I tried it

import breeze.linalg._
import breeze.plot._

object test {
  println("Welcome to the Scala worksheet")
   
    var x = DenseVector(1.0,1.0)
   
    val F = DenseMatrix.ones[Double](2,2)
   
    def state(t: DenseVector[Double]) : DenseVector[Double] =
    {
    t := F * t
  }
 
 
 
  val f = Figure()
  val g = f.subplot(0)
  g.xlim(-100,100)
  g.ylim(-100,100)
 
  for( i <- 0 until 10)
  {
     
      x := state(x)
      g += scatter(x(0 to 0), x(1 to 1), {_=>0.01})
  }
 
   
}

On Windows it shows Frame with no plotting and working in Ubuntu it show no frame even. 


On Thursday, January 10, 2013 8:17:40 PM UTC+1, Adelbert Chang wrote:

KiranKumar Adam

unread,
May 4, 2013, 10:14:56 AM5/4/13
to scala-...@googlegroups.com
Hello David,

Figured out the solution thanks for the wonderful package. In future I'll surely contribute to this package target tracking and localization algorithm very soon.

Regards,
-kirankumar

On Thursday, January 10, 2013 8:17:40 PM UTC+1, Adelbert Chang wrote:

David Hall

unread,
May 4, 2013, 11:59:18 AM5/4/13
to scala-...@googlegroups.com
glad you figured it out!
> --
> You received this message because you are subscribed to the Google Groups
> "Scala Breeze" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scala-breeze...@googlegroups.com.
> To post to this group, send email to scala-...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/scala-breeze/-/5H1G_GKK0zsJ.
Reply all
Reply to author
Forward
0 new messages