Plot library wanted

Laeeth Isharc via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 5 15:40:48 PDT 2015


On Saturday, 5 September 2015 at 19:38:46 UTC, dan wrote:
> On Monday, 27 January 2014 at 12:46:43 UTC, terchestor wrote:
>> ((snipped))
>> Does anyone using PLplot can tell if it's worth using it or is 
>> there any alternative?
>
> Well, this thread is a 1.5 years old but i was looking around 
> for info on plplot also, and it is possible to use it with d, 
> at least on ubuntu 15.04.
>
> Nevertheless, David's package that John and Jordi referred to 
> should also be investigated.

In case of interest, mathgl works well for some uses, and I have 
D bindings (wrapper in process).

http://mathgl.sourceforge.net/doc_en/Main.html
https://github.com/Laeeth/dmathgl


import mgl;

int main()
{
	HMGL gr = mgl_create_graph(600,400);
	if (gr is null)
	{
		writefln("cannot create graph");
		return 0;
	}
	writefln("graph created");
	mgl_fplot(gr,"sin(pi*x)","","");
	writefln("sin plotted");
	sample(gr);
	mgl_write_frame(gr,"test.png","");
	writefln("frame written");
	mgl_delete_graph(gr);
	writefln("graph deleted");
	return 0;
}

int sample(HMGL gr)
{
   auto o=mgl_create_data_size(10,1,1);
   auto h=mgl_create_data_size(10,1,1);
   auto l=mgl_create_data_size(10,1,1);
   auto c=mgl_create_data_size(10,1,1);
   mgl_data_fill_eq(gr,o,"0.5*sin(pi*x)".toStringz,null,null,null);
   
mgl_data_fill_eq(gr,c,"0.5*sin(pi*(x+2/9))".toStringz,null,null,null);
   mgl_data_fill_eq(gr,l,"0.3*rnd-0.8".toStringz,null,null,null);
   mgl_data_fill_eq(gr,h,"0.3*rnd+0.5".toStringz,null,null,null);
   mgl_subplot(gr,1,1,0,"");
   mgl_title(gr,"OHLC plot".toStringz,"".toStringz,1.0);
   mgl_box(gr);
   mgl_ohlc(gr,o,h,l,c,"".toStringz,"".toStringz);
   mgl_puts(gr,0.5,0.5,1.0,"hello".toStringz,"rC".toStringz,10.0);
   return 0;
}



More information about the Digitalmars-d mailing list