1 2 /* 3 Contains the data structure for plotting a histogram in a window with an axis. 4 */ 5 6 #include <petscsys.h> /*I "petscsys.h" I*/ 7 8 PetscClassId PETSC_DRAWHG_CLASSID = 0; 9 10 struct _p_PetscDrawHG { 11 PETSCHEADER(int); 12 PetscErrorCode (*destroy)(PetscDrawSP); 13 PetscErrorCode (*view)(PetscDrawSP,PetscViewer); 14 PetscDraw win; 15 PetscDrawAxis axis; 16 PetscReal xmin,xmax; 17 PetscReal ymin,ymax; 18 int numBins; 19 int maxBins; 20 PetscReal *bins; 21 int numValues; 22 int maxValues; 23 PetscReal *values; 24 int color; 25 PetscBool calcStats; 26 PetscBool integerBins; 27 }; 28 29 #define CHUNKSIZE 100 30 31 #undef __FUNCT__ 32 #define __FUNCT__ "PetscDrawHGCreate" 33 /*@C 34 PetscDrawHGCreate - Creates a histogram data structure. 35 36 Collective over PetscDraw 37 38 Input Parameters: 39 + draw - The window where the graph will be made 40 - bins - The number of bins to use 41 42 Output Parameters: 43 . hist - The histogram context 44 45 Level: intermediate 46 47 Concepts: histogram^creating 48 49 .seealso: PetscDrawHGDestroy() 50 51 @*/ 52 PetscErrorCode PetscDrawHGCreate(PetscDraw draw, int bins, PetscDrawHG *hist) 53 { 54 PetscDrawHG h; 55 MPI_Comm comm; 56 PetscBool isnull; 57 PetscErrorCode ierr; 58 59 PetscFunctionBegin; 60 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID,1); 61 PetscValidPointer(hist,3); 62 ierr = PetscObjectGetComm((PetscObject) draw, &comm);CHKERRQ(ierr); 63 ierr = PetscHeaderCreate(h, _p_PetscDrawHG, int, PETSC_DRAWHG_CLASSID, 0, "PetscDrawHG", "Histogram", "Draw", comm, PetscDrawHGDestroy, PETSC_NULL);CHKERRQ(ierr); 64 h->view = PETSC_NULL; 65 h->destroy = PETSC_NULL; 66 h->win = draw; 67 ierr = PetscObjectReference((PetscObject) draw);CHKERRQ(ierr); 68 h->color = PETSC_DRAW_GREEN; 69 h->xmin = PETSC_MAX_REAL; 70 h->xmax = PETSC_MIN_REAL; 71 h->ymin = 0.; 72 h->ymax = 1.; 73 h->numBins = bins; 74 h->maxBins = bins; 75 ierr = PetscMalloc(h->maxBins * sizeof(PetscReal), &h->bins);CHKERRQ(ierr); 76 h->numValues = 0; 77 h->maxValues = CHUNKSIZE; 78 h->calcStats = PETSC_FALSE; 79 h->integerBins = PETSC_FALSE; 80 ierr = PetscMalloc(h->maxValues * sizeof(PetscReal), &h->values);CHKERRQ(ierr); 81 ierr = PetscLogObjectMemory(h, (h->maxBins + h->maxValues)*sizeof(PetscReal));CHKERRQ(ierr); 82 ierr = PetscObjectTypeCompare((PetscObject) draw, PETSC_DRAW_NULL, &isnull);CHKERRQ(ierr); 83 if (!isnull) { 84 ierr = PetscDrawAxisCreate(draw, &h->axis);CHKERRQ(ierr); 85 ierr = PetscLogObjectParent(h, h->axis);CHKERRQ(ierr); 86 } else { 87 h->axis = PETSC_NULL; 88 } 89 *hist = h; 90 PetscFunctionReturn(0); 91 } 92 93 #undef __FUNCT__ 94 #define __FUNCT__ "PetscDrawHGSetNumberBins" 95 /*@ 96 PetscDrawHGSetNumberBins - Change the number of bins that are to be drawn. 97 98 Not Collective (ignored except on processor 0 of PetscDrawHG) 99 100 Input Parameter: 101 + hist - The histogram context. 102 - dim - The number of curves. 103 104 Level: intermediate 105 106 Concepts: histogram^setting number of bins 107 108 @*/ 109 PetscErrorCode PetscDrawHGSetNumberBins(PetscDrawHG hist, int bins) 110 { 111 PetscErrorCode ierr; 112 113 PetscFunctionBegin; 114 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID,1); 115 if (hist->maxBins < bins) { 116 ierr = PetscFree(hist->bins);CHKERRQ(ierr); 117 ierr = PetscMalloc(bins * sizeof(PetscReal), &hist->bins);CHKERRQ(ierr); 118 ierr = PetscLogObjectMemory(hist, (bins - hist->maxBins) * sizeof(PetscReal));CHKERRQ(ierr); 119 hist->maxBins = bins; 120 } 121 hist->numBins = bins; 122 PetscFunctionReturn(0); 123 } 124 125 #undef __FUNCT__ 126 #define __FUNCT__ "PetscDrawHGReset" 127 /*@ 128 PetscDrawHGReset - Clears histogram to allow for reuse with new data. 129 130 Not Collective (ignored except on processor 0 of PetscDrawHG) 131 132 Input Parameter: 133 . hist - The histogram context. 134 135 Level: intermediate 136 137 Concepts: histogram^resetting 138 @*/ 139 PetscErrorCode PetscDrawHGReset(PetscDrawHG hist) 140 { 141 PetscFunctionBegin; 142 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID,1); 143 hist->xmin = PETSC_MAX_REAL; 144 hist->xmax = PETSC_MIN_REAL; 145 hist->ymin = 0.0; 146 hist->ymax = 0.0; 147 hist->numValues = 0; 148 PetscFunctionReturn(0); 149 } 150 151 #undef __FUNCT__ 152 #define __FUNCT__ "PetscDrawHGDestroy" 153 /*@C 154 PetscDrawHGDestroy - Frees all space taken up by histogram data structure. 155 156 Collective over PetscDrawHG 157 158 Input Parameter: 159 . hist - The histogram context 160 161 Level: intermediate 162 163 .seealso: PetscDrawHGCreate() 164 @*/ 165 PetscErrorCode PetscDrawHGDestroy(PetscDrawHG *hist) 166 { 167 PetscErrorCode ierr; 168 169 PetscFunctionBegin; 170 if (!*hist) PetscFunctionReturn(0); 171 PetscValidHeader(*hist,1); 172 173 if (--((PetscObject)(*hist))->refct > 0) PetscFunctionReturn(0); 174 ierr = PetscDrawAxisDestroy(&(*hist)->axis);CHKERRQ(ierr); 175 ierr = PetscDrawDestroy(&(*hist)->win);CHKERRQ(ierr); 176 ierr = PetscFree((*hist)->bins);CHKERRQ(ierr); 177 ierr = PetscFree((*hist)->values);CHKERRQ(ierr); 178 ierr = PetscHeaderDestroy(hist);CHKERRQ(ierr); 179 PetscFunctionReturn(0); 180 } 181 182 #undef __FUNCT__ 183 #define __FUNCT__ "PetscDrawHGAddValue" 184 /*@ 185 PetscDrawHGAddValue - Adds another value to the histogram. 186 187 Not Collective (ignored except on processor 0 of PetscDrawHG) 188 189 Input Parameters: 190 + hist - The histogram 191 - value - The value 192 193 Level: intermediate 194 195 Concepts: histogram^adding values 196 197 .seealso: PetscDrawHGAddValues() 198 @*/ 199 PetscErrorCode PetscDrawHGAddValue(PetscDrawHG hist, PetscReal value) 200 { 201 PetscFunctionBegin; 202 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID,1); 203 /* Allocate more memory if necessary */ 204 if (hist->numValues >= hist->maxValues) { 205 PetscReal *tmp; 206 PetscErrorCode ierr; 207 208 ierr = PetscMalloc((hist->maxValues+CHUNKSIZE) * sizeof(PetscReal), &tmp);CHKERRQ(ierr); 209 ierr = PetscLogObjectMemory(hist, CHUNKSIZE * sizeof(PetscReal));CHKERRQ(ierr); 210 ierr = PetscMemcpy(tmp, hist->values, hist->maxValues * sizeof(PetscReal));CHKERRQ(ierr); 211 ierr = PetscFree(hist->values);CHKERRQ(ierr); 212 hist->values = tmp; 213 hist->maxValues += CHUNKSIZE; 214 } 215 /* I disagree with the original Petsc implementation here. There should be no overshoot, but rather the 216 stated convention of using half-open intervals (always the way to go) */ 217 if (!hist->numValues) { 218 hist->xmin = value; 219 hist->xmax = value; 220 #if 1 221 } else { 222 /* Update limits */ 223 if (value > hist->xmax) 224 hist->xmax = value; 225 if (value < hist->xmin) 226 hist->xmin = value; 227 #else 228 } else if (hist->numValues == 1) { 229 /* Update limits -- We need to overshoot the largest value somewhat */ 230 if (value > hist->xmax) { 231 hist->xmax = value + 0.001*(value - hist->xmin)/hist->numBins; 232 } 233 if (value < hist->xmin) { 234 hist->xmin = value; 235 hist->xmax = hist->xmax + 0.001*(hist->xmax - hist->xmin)/hist->numBins; 236 } 237 } else { 238 /* Update limits -- We need to overshoot the largest value somewhat */ 239 if (value > hist->xmax) { 240 hist->xmax = value + 0.001*(hist->xmax - hist->xmin)/hist->numBins; 241 } 242 if (value < hist->xmin) { 243 hist->xmin = value; 244 } 245 #endif 246 } 247 248 hist->values[hist->numValues++] = value; 249 PetscFunctionReturn(0); 250 } 251 252 #undef __FUNCT__ 253 #define __FUNCT__ "PetscDrawHGDraw" 254 /*@ 255 PetscDrawHGDraw - Redraws a histogram. 256 257 Not Collective (ignored except on processor 0 of PetscDrawHG) 258 259 Input Parameter: 260 . hist - The histogram context 261 262 Level: intermediate 263 264 @*/ 265 PetscErrorCode PetscDrawHGDraw(PetscDrawHG hist) 266 { 267 PetscDraw draw = hist->win; 268 PetscBool isnull; 269 PetscReal xmin,xmax,ymin,ymax,*bins,*values,binSize,binLeft,binRight,maxHeight,mean,var; 270 char title[256]; 271 char xlabel[256]; 272 PetscInt numBins,numBinsOld,numValues,initSize,i,p,bcolor,color; 273 PetscErrorCode ierr; 274 275 PetscFunctionBegin; 276 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID,1); 277 ierr = PetscObjectTypeCompare((PetscObject) draw, PETSC_DRAW_NULL, &isnull);CHKERRQ(ierr); 278 if (isnull) PetscFunctionReturn(0); 279 if ((hist->xmin >= hist->xmax) || (hist->ymin >= hist->ymax)) PetscFunctionReturn(0); 280 if (hist->numValues < 1) PetscFunctionReturn(0); 281 282 #if 0 283 ierr = MPI_Comm_rank(((PetscObject)hist)->comm,&rank);CHKERRQ(ierr); 284 if (rank) PetscFunctionReturn(0); 285 #endif 286 287 color = hist->color; 288 if (color == PETSC_DRAW_ROTATE) {bcolor = 2;} else {bcolor = color;} 289 xmin = hist->xmin; 290 xmax = hist->xmax; 291 ymin = hist->ymin; 292 ymax = hist->ymax; 293 numValues = hist->numValues; 294 values = hist->values; 295 mean = 0.0; 296 var = 0.0; 297 298 ierr = PetscDrawClear(draw);CHKERRQ(ierr); 299 if (xmin == xmax) { 300 /* Calculate number of points in each bin */ 301 bins = hist->bins; 302 bins[0] = 0.; 303 for (p = 0; p < numValues; p++) { 304 if (values[p] == xmin) bins[0]++; 305 mean += values[p]; 306 var += values[p]*values[p]; 307 } 308 maxHeight = bins[0]; 309 if (maxHeight > ymax) ymax = hist->ymax = maxHeight; 310 xmax = xmin + 1; 311 ierr = PetscDrawAxisSetLimits(hist->axis, xmin, xmax, ymin, ymax);CHKERRQ(ierr); 312 if (hist->calcStats) { 313 mean /= numValues; 314 if (numValues > 1) { 315 var = (var - numValues*mean*mean) / (numValues-1); 316 } else { 317 var = 0.0; 318 } 319 ierr = PetscSNPrintf(title, 256, "Mean: %g Var: %g", (double)mean, (double)var);CHKERRQ(ierr); 320 ierr = PetscSNPrintf(xlabel,256, "Total: %D", numValues);CHKERRQ(ierr); 321 ierr = PetscDrawAxisSetLabels(hist->axis, title, xlabel, PETSC_NULL);CHKERRQ(ierr); 322 } 323 ierr = PetscDrawAxisDraw(hist->axis);CHKERRQ(ierr); 324 /* Draw bins */ 325 binLeft = xmin; 326 binRight = xmax; 327 ierr = PetscDrawRectangle(draw,binLeft,ymin,binRight,bins[0],bcolor,bcolor,bcolor,bcolor);CHKERRQ(ierr); 328 if (color == PETSC_DRAW_ROTATE && bins[0] != 0.0) bcolor++; if (bcolor > 31) bcolor = 2; 329 ierr = PetscDrawLine(draw,binLeft,ymin,binLeft,bins[0],PETSC_DRAW_BLACK);CHKERRQ(ierr); 330 ierr = PetscDrawLine(draw,binRight,ymin,binRight,bins[0],PETSC_DRAW_BLACK);CHKERRQ(ierr); 331 ierr = PetscDrawLine(draw,binLeft,bins[0],binRight,bins[0],PETSC_DRAW_BLACK);CHKERRQ(ierr); 332 } else { 333 numBins = hist->numBins; 334 numBinsOld = hist->numBins; 335 if (hist->integerBins && (((int) xmax - xmin) + 1.0e-05 > xmax - xmin)) { 336 initSize = (int) ((int) xmax - xmin)/numBins; 337 while (initSize*numBins != (int) xmax - xmin) { 338 initSize = PetscMax(initSize - 1, 1); 339 numBins = (int) ((int) xmax - xmin)/initSize; 340 ierr = PetscDrawHGSetNumberBins(hist, numBins);CHKERRQ(ierr); 341 } 342 } 343 binSize = (xmax - xmin)/numBins; 344 bins = hist->bins; 345 346 ierr = PetscMemzero(bins, numBins * sizeof(PetscReal));CHKERRQ(ierr); 347 maxHeight = 0.0; 348 for (i = 0; i < numBins; i++) { 349 binLeft = xmin + binSize*i; 350 binRight = xmin + binSize*(i+1); 351 for (p = 0; p < numValues; p++) { 352 if ((values[p] >= binLeft) && (values[p] < binRight)) bins[i]++; 353 /* Handle last bin separately */ 354 if ((i == numBins-1) && (values[p] == binRight)) bins[i]++; 355 if (!i) { 356 mean += values[p]; 357 var += values[p]*values[p]; 358 } 359 } 360 maxHeight = PetscMax(maxHeight, bins[i]); 361 } 362 if (maxHeight > ymax) ymax = hist->ymax = maxHeight; 363 364 ierr = PetscDrawAxisSetLimits(hist->axis, xmin, xmax, ymin, ymax);CHKERRQ(ierr); 365 if (hist->calcStats) { 366 mean /= numValues; 367 if (numValues > 1) { 368 var = (var - numValues*mean*mean) / (numValues-1); 369 } else { 370 var = 0.0; 371 } 372 ierr = PetscSNPrintf(title, 256,"Mean: %g Var: %g", (double)mean, (double)var);CHKERRQ(ierr); 373 ierr = PetscSNPrintf(xlabel,256, "Total: %D", numValues);CHKERRQ(ierr); 374 ierr = PetscDrawAxisSetLabels(hist->axis, title, xlabel, PETSC_NULL);CHKERRQ(ierr); 375 } 376 ierr = PetscDrawAxisDraw(hist->axis);CHKERRQ(ierr); 377 /* Draw bins */ 378 for (i = 0; i < numBins; i++) { 379 binLeft = xmin + binSize*i; 380 binRight = xmin + binSize*(i+1); 381 ierr = PetscDrawRectangle(draw,binLeft,ymin,binRight,bins[i],bcolor,bcolor,bcolor,bcolor);CHKERRQ(ierr); 382 if (color == PETSC_DRAW_ROTATE && bins[i]) bcolor++; if (bcolor > 31) bcolor = 2; 383 ierr = PetscDrawLine(draw,binLeft,ymin,binLeft,bins[i],PETSC_DRAW_BLACK);CHKERRQ(ierr); 384 ierr = PetscDrawLine(draw,binRight,ymin,binRight,bins[i],PETSC_DRAW_BLACK);CHKERRQ(ierr); 385 ierr = PetscDrawLine(draw,binLeft,bins[i],binRight,bins[i],PETSC_DRAW_BLACK);CHKERRQ(ierr); 386 } 387 ierr = PetscDrawHGSetNumberBins(hist, numBinsOld);CHKERRQ(ierr); 388 } 389 ierr = PetscDrawSynchronizedFlush(draw);CHKERRQ(ierr); 390 ierr = PetscDrawPause(draw);CHKERRQ(ierr); 391 PetscFunctionReturn(0); 392 } 393 394 #undef __FUNCT__ 395 #define __FUNCT__ "PetscDrawHGPrint" 396 /*@ 397 PetscDrawHGPrint - Prints the histogram information. 398 399 Not collective 400 401 Input Parameter: 402 . hist - The histogram context 403 404 Level: beginner 405 406 .keywords: draw, histogram 407 @*/ 408 PetscErrorCode PetscDrawHGPrint(PetscDrawHG hist) 409 { 410 PetscReal xmax,xmin,*bins,*values,binSize,binLeft,binRight,mean,var; 411 PetscErrorCode ierr; 412 PetscInt numBins,numBinsOld,numValues,initSize,i,p; 413 414 PetscFunctionBegin; 415 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID,1); 416 if ((hist->xmin > hist->xmax) || (hist->ymin >= hist->ymax)) PetscFunctionReturn(0); 417 if (hist->numValues < 1) PetscFunctionReturn(0); 418 419 xmax = hist->xmax; 420 xmin = hist->xmin; 421 numValues = hist->numValues; 422 values = hist->values; 423 mean = 0.0; 424 var = 0.0; 425 if (xmax == xmin) { 426 /* Calculate number of points in the bin */ 427 bins = hist->bins; 428 bins[0] = 0.; 429 for (p = 0; p < numValues; p++) { 430 if (values[p] == xmin) bins[0]++; 431 mean += values[p]; 432 var += values[p]*values[p]; 433 } 434 /* Draw bins */ 435 PetscPrintf(((PetscObject)hist)->comm, "Bin %2d (%6.2g - %6.2g): %.0g\n", 0, xmin, xmax, bins[0]); 436 } else { 437 numBins = hist->numBins; 438 numBinsOld = hist->numBins; 439 if (hist->integerBins && (((int) xmax - xmin) + 1.0e-05 > xmax - xmin)) { 440 initSize = (int) ((int) xmax - xmin)/numBins; 441 while (initSize*numBins != (int) xmax - xmin) { 442 initSize = PetscMax(initSize - 1, 1); 443 numBins = (int) ((int) xmax - xmin)/initSize; 444 ierr = PetscDrawHGSetNumberBins(hist, numBins);CHKERRQ(ierr); 445 } 446 } 447 binSize = (xmax - xmin)/numBins; 448 bins = hist->bins; 449 450 /* Calculate number of points in each bin */ 451 ierr = PetscMemzero(bins, numBins * sizeof(PetscReal));CHKERRQ(ierr); 452 for (i = 0; i < numBins; i++) { 453 binLeft = xmin + binSize*i; 454 binRight = xmin + binSize*(i+1); 455 for (p = 0; p < numValues; p++) { 456 if ((values[p] >= binLeft) && (values[p] < binRight)) bins[i]++; 457 /* Handle last bin separately */ 458 if ((i == numBins-1) && (values[p] == binRight)) bins[i]++; 459 if (!i) { 460 mean += values[p]; 461 var += values[p]*values[p]; 462 } 463 } 464 } 465 /* Draw bins */ 466 for (i = 0; i < numBins; i++) { 467 binLeft = xmin + binSize*i; 468 binRight = xmin + binSize*(i+1); 469 PetscPrintf(((PetscObject)hist)->comm, "Bin %2d (%6.2g - %6.2g): %.0g\n", i, binLeft, binRight, bins[i]); 470 } 471 ierr = PetscDrawHGSetNumberBins(hist, numBinsOld);CHKERRQ(ierr); 472 } 473 474 if (hist->calcStats) { 475 mean /= numValues; 476 if (numValues > 1) { 477 var = (var - numValues*mean*mean) / (numValues-1); 478 } else { 479 var = 0.0; 480 } 481 PetscPrintf(((PetscObject)hist)->comm, "Mean: %G Var: %G\n", mean, var); 482 PetscPrintf(((PetscObject)hist)->comm, "Total: %d\n", numValues); 483 } 484 PetscFunctionReturn(0); 485 } 486 487 #undef __FUNCT__ 488 #define __FUNCT__ "PetscDrawHGSetColor" 489 /*@ 490 PetscDrawHGSetColor - Sets the color the bars will be drawn with. 491 492 Not Collective (ignored except on processor 0 of PetscDrawHG) 493 494 Input Parameters: 495 + hist - The histogram context 496 - color - one of the colors defined in petscdraw.h or PETSC_DRAW_ROTATE to make each bar a 497 different color 498 499 Level: intermediate 500 501 @*/ 502 PetscErrorCode PetscDrawHGSetColor(PetscDrawHG hist, int color) 503 { 504 PetscFunctionBegin; 505 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID,1); 506 hist->color = color; 507 PetscFunctionReturn(0); 508 } 509 510 #undef __FUNCT__ 511 #define __FUNCT__ "PetscDrawHGSetLimits" 512 /*@ 513 PetscDrawHGSetLimits - Sets the axis limits for a histogram. If more 514 points are added after this call, the limits will be adjusted to 515 include those additional points. 516 517 Not Collective (ignored except on processor 0 of PetscDrawHG) 518 519 Input Parameters: 520 + hist - The histogram context 521 - x_min,x_max,y_min,y_max - The limits 522 523 Level: intermediate 524 525 Concepts: histogram^setting axis 526 @*/ 527 PetscErrorCode PetscDrawHGSetLimits(PetscDrawHG hist, PetscReal x_min, PetscReal x_max, int y_min, int y_max) 528 { 529 PetscFunctionBegin; 530 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID,1); 531 hist->xmin = x_min; 532 hist->xmax = x_max; 533 hist->ymin = y_min; 534 hist->ymax = y_max; 535 PetscFunctionReturn(0); 536 } 537 538 #undef __FUNCT__ 539 #define __FUNCT__ "PetscDrawHGCalcStats" 540 /*@ 541 PetscDrawHGCalcStats - Turns on calculation of descriptive statistics 542 543 Not collective 544 545 Input Parameters: 546 + hist - The histogram context 547 - calc - Flag for calculation 548 549 Level: intermediate 550 551 .keywords: draw, histogram, statistics 552 553 @*/ 554 PetscErrorCode PetscDrawHGCalcStats(PetscDrawHG hist, PetscBool calc) 555 { 556 PetscFunctionBegin; 557 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID,1); 558 hist->calcStats = calc; 559 PetscFunctionReturn(0); 560 } 561 562 #undef __FUNCT__ 563 #define __FUNCT__ "PetscDrawHGIntegerBins" 564 /*@ 565 PetscDrawHGIntegerBins - Turns on integer width bins 566 567 Not collective 568 569 Input Parameters: 570 + hist - The histogram context 571 - ints - Flag for integer width bins 572 573 Level: intermediate 574 575 .keywords: draw, histogram, statistics 576 @*/ 577 PetscErrorCode PetscDrawHGIntegerBins(PetscDrawHG hist, PetscBool ints) 578 { 579 PetscFunctionBegin; 580 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID,1); 581 hist->integerBins = ints; 582 PetscFunctionReturn(0); 583 } 584 585 #undef __FUNCT__ 586 #define __FUNCT__ "PetscDrawHGGetAxis" 587 /*@C 588 PetscDrawHGGetAxis - Gets the axis context associated with a histogram. 589 This is useful if one wants to change some axis property, such as 590 labels, color, etc. The axis context should not be destroyed by the 591 application code. 592 593 Not Collective (ignored except on processor 0 of PetscDrawHG) 594 595 Input Parameter: 596 . hist - The histogram context 597 598 Output Parameter: 599 . axis - The axis context 600 601 Level: intermediate 602 603 @*/ 604 PetscErrorCode PetscDrawHGGetAxis(PetscDrawHG hist, PetscDrawAxis *axis) 605 { 606 PetscFunctionBegin; 607 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID,1); 608 PetscValidPointer(axis,2); 609 *axis = hist->axis; 610 PetscFunctionReturn(0); 611 } 612 613 #undef __FUNCT__ 614 #define __FUNCT__ "PetscDrawHGGetDraw" 615 /*@C 616 PetscDrawHGGetDraw - Gets the draw context associated with a histogram. 617 618 Not Collective, PetscDraw is parallel if PetscDrawHG is parallel 619 620 Input Parameter: 621 . hist - The histogram context 622 623 Output Parameter: 624 . win - The draw context 625 626 Level: intermediate 627 628 @*/ 629 PetscErrorCode PetscDrawHGGetDraw(PetscDrawHG hist, PetscDraw *win) 630 { 631 PetscFunctionBegin; 632 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID,1); 633 PetscValidPointer(win,2); 634 *win = hist->win; 635 PetscFunctionReturn(0); 636 } 637 638