From: <hez...@us...> - 2010-09-10 22:41:40
|
Revision: 11165 http://plplot.svn.sourceforge.net/plplot/?rev=11165&view=rev Author: hezekiahcarty Date: 2010-09-10 22:41:34 +0000 (Fri, 10 Sep 2010) Log Message: ----------- Initial C implementation of pllegend This function allows one to draw basic line and point/symbol legends. It is based on the OCaml draw_legend function and somewhat generalized from that original version. Modified Paths: -------------- trunk/examples/c/x04c.c trunk/include/plplot.h trunk/src/CMakeLists.txt Modified: trunk/examples/c/x04c.c =================================================================== --- trunk/examples/c/x04c.c 2010-09-10 22:31:48 UTC (rev 11164) +++ trunk/examples/c/x04c.c 2010-09-10 22:41:34 UTC (rev 11165) @@ -46,6 +46,10 @@ int i; static PLFLT freql[101], ampl[101], phase[101]; PLFLT f0, freq; + char *names[2]; + int colors[2]; + int label_colors[2]; + int symbols[2]; pladv( 0 ); @@ -100,7 +104,24 @@ plbox( "", 0.0, 0, "cmstv", 30.0, 3 ); plcol0( 3 ); plline( 101, freql, phase ); + plpoin( 101, freql, phase, 3 ); plcol0( 3 ); plmtex( "r", 5.0, 0.5, 0.5, "Phase shift (degrees)" ); + + // Draw a legend + names[0] = "Amplitude"; + names[1] = "Phase shift"; + colors[0] = 2; + colors[1] = 3; + label_colors[0] = 1; + label_colors[1] = 1; + pllegend( 1.0, 0.6, 0.95, 2, label_colors, names, colors, NULL ); + + // Draw the points legend + names[0] = ""; + names[1] = ""; + symbols[0] = -1; + symbols[1] = 3; + pllegend( 1.0, 0.6, 0.95, 2, label_colors, names, colors, symbols ); } } Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2010-09-10 22:31:48 UTC (rev 11164) +++ trunk/include/plplot.h 2010-09-10 22:41:34 UTC (rev 11165) @@ -686,6 +686,7 @@ #define plinit c_plinit #define pljoin c_pljoin #define pllab c_pllab +#define pllegend c_pllegend #define pllightsource c_pllightsource #define plline c_plline #define plpath c_plpath @@ -1204,6 +1205,10 @@ PLDLLIMPEXP void c_pllab( const char *xlabel, const char *ylabel, const char *tlabel ); +/* Routine for drawing simple line or symbol legends */ +PLDLLIMPEXP void +c_pllegend( PLFLT line_length, PLFLT x, PLFLT y, PLINT n, PLINT *text_colors, char **names, PLINT *colors, PLINT *symbols ); + /* Sets position of the light source */ PLDLLIMPEXP void c_pllightsource( PLFLT x, PLFLT y, PLFLT z ); Modified: trunk/src/CMakeLists.txt =================================================================== --- trunk/src/CMakeLists.txt 2010-09-10 22:31:48 UTC (rev 11164) +++ trunk/src/CMakeLists.txt 2010-09-10 22:41:34 UTC (rev 11165) @@ -55,6 +55,7 @@ plvect.c mt19937ar.c pltime.c + pllegend.c ) if(LTDL_WIN32) set(plplot${LIB_TAG}_LIB_SRCS ${plplot${LIB_TAG}_LIB_SRCS} ltdl_win32.c) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |