tablename = 'C:\Users\Silas\Documents\latex\JLT_400G_submission\HighSpeedExperiments_oneandonly_csv.csv'; % Returns a Table data = readtable(tablename,"Delimiter",';','DecimalSeparator',','); %% ============================================================ % PLOT % ============================================================ %% 1. DATA EXTRACTION & SETUP %% 1. DATA EXTRACTION & SETUP raw_M = data.M; raw_baud = data.BaudRate; raw_net = data.NetRate; raw_codes = string(data.ZoteroCode); raw_names = string(data.Name); raw_band = string(data.Band); % Filter Valid Data target_M = [2, 4, 6, 8]; validIdx = ismember(raw_M, target_M) & ~isnan(raw_baud) & ~isnan(raw_net); Mvals = raw_M(validIdx); baud = raw_baud(validIdx); netrate = raw_net(validIdx); codes = raw_codes(validIdx); names = raw_names(validIdx); bands = raw_band(validIdx); pam_list = target_M; colors = flip(cbrewer2('SET1',4)); %% 2. PLOT (For Visual Check only) figure; hold on; ms = 20; lw = 0.5; for k = 1:length(pam_list) M = pam_list(k); idxPam = (Mvals == M); x = baud(idxPam); y = netrate(idxPam); b = bands(idxPam); n = names(idxPam); col = colors(k,:); firstLegend = true; for i = 1:sum(idxPam) % Marker Logic ms = 20; if strcmpi(b(i), 'O') marker = 'o'; elseif strcmpi(b(i), 'C') marker = 'd'; else marker = 's'; end if strcmpi(n(i), 'THIS WORK') marker = 'pentagram'; ms = 100; end % Plot Scatter if firstLegend scatter(x(i), y(i), ms, 'Marker', marker, ... 'MarkerEdgeColor', col, 'MarkerFaceColor', col, ... 'DisplayName', sprintf('PAM-%d', M)); firstLegend = false; else scatter(x(i), y(i), ms, 'Marker', marker, ... 'MarkerEdgeColor', col, 'MarkerFaceColor', col, ... 'HandleVisibility','off'); end end % Fit lines if length(x) >= 3 [p, S, mu] = polyfit(x, y, 2); xfit = linspace(min(x), max(x), 200); yfit = polyval(p, xfit, S, mu); plot(xfit, yfit, '-', 'LineWidth', lw, 'Color', col, 'HandleVisibility', 'off'); end end grid on; box on; xlabel('Baud rate [GBd]'); ylabel('Net rate [Gb/s]'); % title('Check Command Window for TikZ Code'); % legend('Location','northwest'); %% 3. GENERATE TIKZ ANNOTATION CODE % This prints the manual \draw commands to the console %% GENERATE TIKZ ANNOTATION CODE % This prints the manual \draw commands to the console %% GENERATE TIKZ ANNOTATION CODE (Colored Borders + Tiny Font) %% GENERATE TIKZ ANNOTATION CODE (No Arrow, Close Text) fprintf('\n\n%% ===========================================================\n'); fprintf('%% COPY THE FOLLOWING LINES INTO YOUR .TEX FILE \n'); fprintf('%% (Paste them just before \\end{axis})\n'); fprintf('%% ===========================================================\n\n'); for i = 1:length(baud) bx = baud(i); by = netrate(i); key = codes(i); M_val = Mvals(i); % --- PLACEMENT LOGIC --- if M_val == 8 % PAM-8: Place Top-Left % 'south east' anchor means the text's bottom-right corner touches the coordinate % shift moves it slightly up and left to clear the marker anchorStr = 'south east'; shiftStr = 'shift={(-3pt, 3pt)}'; else % Others: Place Bottom-Right % 'north west' anchor means the text's top-left corner touches the coordinate % shift moves it slightly down and right anchorStr = 'north west'; shiftStr = 'shift={(3pt, -3pt)}'; end % --- PRINT COMMAND --- % Uses \node directly at the coordinate (axis cs:...) fprintf('\\node[anchor=%s, %s, font=\\tiny, fill=white, inner sep=1pt] at (axis cs:%.2f, %.2f) {\\cite{%s}};\n', ... anchorStr, shiftStr, bx, by, key); end fprintf('\n') %% === EXPORT === outfile = 'C:\Users\Silas\Documents\latex\JLT_400G_submission\media\matlab2tikz\highspeedresults_test.tikz'; matlab2tikz(outfile, ... 'width','\fwidth', ... 'height','\fheight', ... 'showInfo',false, ... 'extraAxisOptions',{ ... 'legend style={font=\footnotesize}', ... 'legend columns=1' ... });