DPlot Forum Index DPlot
http://www.dplot.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Displaying one curve and a specific point.

 
Post new topic   Reply to topic    DPlot Forum Index -> C, C++, C#
View previous topic :: View next topic  
Author Message
Sadbrute



Joined: 26 Apr 2011
Posts: 14

PostPosted: Thu May 19, 2011 4:37 pm    Post subject: Displaying one curve and a specific point. Reply with quote

Do you have a small code snipplet (in C++) on how to draw an arrow that points on a spot (point) on a graph?
With the arrow, dotted lines that goes on the respective coordinates (X,Y) of that specefic point on the graph .

THX!
Back to top
View user's profile Send private message
Sadbrute



Joined: 26 Apr 2011
Posts: 14

PostPosted: Fri May 20, 2011 9:53 am    Post subject: Reply with quote

Here is some code but i get processing error [Activate(2)] and does not work at all i get a striaight line,instaed of a curve and the doted lines are supposed to be "square" on the axis'.

Code:
memset(&dplot_,0,sizeof(dplot_));
   dplot_.Version      = DPLOT_DDE_VERSION;
   dplot_.DataFormat   = DATA_DXY;
   dplot_.hwnd=(DWORD)GetDlgItem(hwnd_,id_);
   dplot_.MaxCurves      = 2;   // Must be >= number of curves we plot
   dplot_.MaxPoints      = 2*calcul->GetNbPoints();   // Anything >= NP will do
   dplot_.NumCurves      = 2;
   dplot_.Scale         = SCALE_LINEARX_LINEARY;
   dplot_.LegendX      = 0;
   dplot_.LegendY      = 0;
   dplot_.NP[0]      = 3;
   

   //legend stuff no problem there....
   
      

   
      strcpy(dplot_.Title[0],info->name);
   strcpy(dplot_.XAxis,info->unit);
   strcpy(dplot_.YAxis,"Celscius");
      
   sprintf(szExec,"[Color(2,255,0,0)][LineWidth(2,20)]");
   dplot_.NP[1]= calcul->GetNbPoints();
   dplot_.LineType[1]   = LINESTYLE_SOLID;

   for (int i=0;i<calcul->GetNbPoints();++i)
   {
      y[i+3]=tab[i].Y;
      x[i+3]=calcul->GetX(i)*1000;
   }
   
   char guedille=34;
   //guedille=34;
   x[0] =2600;
   y[0] = 0;
   x[1] =2600;
   y[1] = Value;
   x[2]=0;
   y[2]=Value;
   strcat(szExec,"[Color(1,0,0,0)] [LineWidth(1,20)]");
   dplot_.LineType[0]  =LINESTYLE_DOTTED;
   strcat(szExec,"[SelectCurve(1)][TextPointLabel(2,1000,50,0,0,8,");
      strcat(szExec,"\"1500\"");
      strcat(szExec,")]");


   
   strcat(szExec,"[LegendParams(0.1,5,1");
   if(CalculManager::GetInstance().IsLegendOpaqueShown())
      strcat(szExec,",1)]");
   else
      strcat(szExec,",0)]");

      strcat(szExec,"[ClearEditFlag()]");

P.S. X array and Y array are valid
Back to top
View user's profile Send private message
Sadbrute



Joined: 26 Apr 2011
Posts: 14

PostPosted: Fri May 20, 2011 11:29 am    Post subject: Reply with quote

Ok i have fixed the Activate(2) problem. I have a plot of 3 points.


it should give me a rectangle with the axis instead i have this:


aaa/--------------
aa/
a /
/


With this code:

Code:
memset(&dplot_,0,sizeof(dplot_));
   dplot_.Version      = DPLOT_DDE_VERSION;
   dplot_.DataFormat   = DATA_DXY;
   dplot_.hwnd=(DWORD)GetDlgItem(hwnd_,id_);
   dplot_.MaxCurves      = 1;   // Must be >= number of curves we plot
   dplot_.MaxPoints      = 3;//2*calcul->GetNbPoints();   // Anything >= NP will do
   dplot_.NumCurves      = 1;
   dplot_.Scale         = SCALE_LINEARX_LINEARY;
   dplot_.LegendX      = 0;
   dplot_.LegendY      = 0;
   dplot_.NP[0]      = 3;
                x[0] =2600.0;
   y[0] = 0;
   x[1] =2600.0;
   y[1] = PPRTable->Value;
   x[2]=2500;
   y[2]=PPRTable->Value;
   dplot_.LineType[0]  =LINESTYLE_DOTTED;
   sprintf(szExec,"[Color(1,0,255,0)]");
      
   
   strcat(szExec,"[ClearEditFlag()]");
Back to top
View user's profile Send private message
Sadbrute



Joined: 26 Apr 2011
Posts: 14

PostPosted: Fri May 20, 2011 12:37 pm    Post subject: Reply with quote

Ahhhhhhhhhhh X[0] determines the jumps and x[1] the start, if i want a graph with my custom points do i need to use XY macro?
Back to top
View user's profile Send private message
Sadbrute



Joined: 26 Apr 2011
Posts: 14

PostPosted: Fri May 20, 2011 2:51 pm    Post subject: Reply with quote

Is there a way to to point out a specific point ,like put a dot on the curve and have (doted) lines that point to it's respective XY coordinates?

P.S i know you have the TextPointLabel macro!
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Fri May 20, 2011 3:24 pm    Post subject: Reply with quote

"if i want a graph with my custom points do i need to use XY macro?"

I'm not sure I understand your question. If your points are not even spaced in X, use DataFormat = DATA_XYXY.

"Is there a way to to point out a specific point ,like put a dot on the curve and have (doted) lines that point to it's respective XY coordinates? "

Other than point labels, no - at least not easily. You can always duplicate the important points, placing them in a different curve with a different symbol/color/size.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sadbrute



Joined: 26 Apr 2011
Posts: 14

PostPosted: Fri May 20, 2011 4:42 pm    Post subject: Reply with quote

NOOOOOOOOOOOOOOO! way!! Thx , wow i feel dumb....

By the way, when does the 64 bit version come out Wink
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Fri May 20, 2011 5:39 pm    Post subject: Reply with quote

If you're talking about dplotlib.dll... I'm working on it, and I do see the importance of this. For dplot.exe I don't, so much. I don't see much value in plotting more points than the 32-bit version will handle.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mad2Max



Joined: 03 Jan 2007
Posts: 16

PostPosted: Mon Feb 13, 2012 8:18 am    Post subject: Reply with quote

Hi,
I add my question to this post because it looks quite similar.
I would like to add one dot on a specific point in a curve - just one.
The problem is that I always keep getting point (0,0) besides my defined point.
Do you have any suggestion on how to get rid of it?
I attach a piece of code.
Thanks!
Max

DPlot.Version = DPLOT_DDE_VERSION;
DPlot.DataFormat = DATA_XYXY;
DPlot.MaxCurves = 2;
DPlot.MaxPoints = NP;
DPlot.NumCurves = 2;
DPlot.Scale = SCALE_LINEARX_LINEARY;
DPlot.LegendX = 0.01f;
DPlot.LegendY = 0.02f;
DPlot.NP[0] = NP;
DPlot.NP[1] = 1;
DPlot.LineType[0] = LINESTYLE_SOLID;
DPlot.LineType[1] = LINESTYLE_NONE;
DPlot.SymbolType[0] = SYMBOLSTYLE_NONE;
DPlot.SymbolType[1] = SYMBOLSTYLE_ASTERISK;

//First curve
DocNum = dPlot_Plot8(&DPlot,x,y,"[DocMaximize()]""[ClearEditFlag()]");
DPlot_Command(DocNum, total_string);
DPlot_Command(DocNum,"[ManualScale(0,,27,,)][ClearEditFlag()]");

//just one point
x1[0]=5.0;
y1[0]=8;
ret = DPlot_AddData8(DocNum, DATA_XYXY, 1, 2, x1, y1);
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Mon Feb 13, 2012 8:35 am    Post subject: Reply with quote

Your initial call to dPlot_Plot8 has DPlot.NumCurves=2, but you don't have the 2nd "curve" to add yet. dPlot_Plot8 will add a curve with whatever values happen to be stored in your x and y arrays after the end of your first curve - in this case 0,0.

Set DPlot.NumCurves=1 and I think you'll get the expected results.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mad2Max



Joined: 03 Jan 2007
Posts: 16

PostPosted: Mon Feb 13, 2012 12:36 pm    Post subject: Reply with quote

Thank you for your answer, you've made my thoughts clearer.
At last DPlot_AddData wasn't the smartest way for my needs and I switched to add the dot on the first curve by adding it to the first vector plotted by dPlot_Plot8.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    DPlot Forum Index -> C, C++, C# All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group